Changing datasource property of datagrid at runtime...


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Changing datasource property of datagrid at runtime...

  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, 11:40 PM
  2. Re: App Object (fixes)
    By Rob Teixeira in forum .NET
    Replies: 129
    Last Post: 06-06-2002, 06:23 AM
  3. App Object
    By Rob Teixeira in forum .NET
    Replies: 15
    Last Post: 05-31-2002, 04:30 PM
  4. Usercontrol's never been terminated
    By Rattagarn V. in forum VB Classic
    Replies: 5
    Last Post: 10-09-2000, 08:36 AM
  5. Replies: 2
    Last Post: 05-10-2000, 07:29 PM

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


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center