-
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??
-
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..
Similar Threads
-
Replies: 146
Last Post: 08-12-2002, 10:40 PM
-
By Rob Teixeira in forum .NET
Replies: 129
Last Post: 06-06-2002, 05:23 AM
-
By Rob Teixeira in forum .NET
Replies: 15
Last Post: 05-31-2002, 03:30 PM
-
By Rattagarn V. in forum VB Classic
Replies: 5
Last Post: 10-09-2000, 07:36 AM
-
By ron tyndall in forum VB Classic
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
Forum Rules
|
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
|
Bookmarks