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?? :confused: