DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2005
    Posts
    22

    Question Changing datasource property of datagrid at runtime...

    In my asp.net application, I have a datagrid control which is bound to Employees datatable in my dataset at DESIGN time, this dataset inturn gets populated from Northwind databse thro a dataadapter control...fine. It also has a button, in the event handler of this button, i have instantiated a dataview on the same Employees datatable in my dataset and sorted it on "City" column. Then i changed the datasource property of the datagrid to this dataview and finally used the databind method on datagrid to bind to this dataview. But at runtime, when i click this button, no sorting happens, instead the list gets displayed as it is, unsorted after the round trip. i did lots of permutations and combinations but in vain. Then at last when i removed the datasource property of datagrid at design time, UNtouching my .cs file, it works perfectly fine!! i dnt know why? it means there is no way to change or override the designtime datasource property of datagrid by the code at runtime??

    private void Button1_Click(object sender, System.EventArgs e)
    {
    sqlDataAdapter1.Fill(dsEmployees1);
    DataView dv = new DataView(dsEmployees1.Tables["Employees"]);
    dv.Sort = "City";
    DataGrid1.DataSource=dv;
    DataGrid1.DataBind();
    DataGrid1.BorderColor = System.Drawing.Color.Green;
    }

    as one can see i am able to OVERRIDE designtime bordercolor of datagrid at runtime, why not datasource then??

  2. #2
    Join Date
    Dec 2004
    Posts
    717
    normally, we can overides the datasource property also.. may be you can post your program in our forum. After checking your program, I hope that we can say something about your problem..
    Best Regards,
    Michael Sync
    http://michaelsync.net

    The more you share,The more you get

Similar Threads

  1. How long before the next version??
    By _CAG in forum .NET
    Replies: 146
    Last Post: 08-12-2002, 10:40 PM
  2. Re: App Object (fixes)
    By Rob Teixeira in forum .NET
    Replies: 129
    Last Post: 06-06-2002, 05:23 AM
  3. App Object
    By Rob Teixeira in forum .NET
    Replies: 15
    Last Post: 05-31-2002, 03:30 PM
  4. Usercontrol's never been terminated
    By Rattagarn V. in forum VB Classic
    Replies: 5
    Last Post: 10-09-2000, 07:36 AM
  5. Replies: 2
    Last Post: 05-10-2000, 06:29 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links