DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2005

    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)
    DataView dv = new DataView(dsEmployees1.Tables["Employees"]);
    dv.Sort = "City";
    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
    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

    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

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
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

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

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.