|
-
Oct 25th, 2005, 05:34 AM
#1
Thread Starter
Fanatic Member
Sort DataGrid
I am having trouble sorting a datagrid. I am also trying to get answers on ASP.NET web site... http://forums.asp.net/1085845/ShowPost.aspx
But I am not getting any help.
If you check that post, you will see a link where you can see my web app and also download the solution.
When I click a header text to sort, the grid empties all it's data leaving just the grid. NOTE: I also am using paging.
Anyone help?
Thanks
-
Oct 25th, 2005, 07:13 AM
#2
Addicted Member
Re: Sort DataGrid
Are you rebinding the grid after you have sorted the data in code?
-
Oct 25th, 2005, 06:43 PM
#3
Thread Starter
Fanatic Member
Re: Sort DataGrid
You can view my web app at...
http://www.ourwebzone.com/codebase/index.aspx
You can download the entire VS 2003 .NET solution here...
http://www.ourwebzone.com/owzdepot/codebase.zip
Take a look and see what you can find.
Thanks
.
-
Oct 25th, 2005, 06:45 PM
#4
Thread Starter
Fanatic Member
Re: Sort DataGrid
 Originally Posted by Patch21
Are you rebinding the grid after you have sorted the data in code?
Yes... I am binding afterwards.
-
Oct 26th, 2005, 04:44 AM
#5
Addicted Member
Re: Sort DataGrid
All I can think of is that your dataview on postback is empty, as you fill it in your InitializeComponent method. Is the dataview empty on postback? If so, you need to get the data on each postback.
-
Oct 26th, 2005, 06:03 AM
#6
Thread Starter
Fanatic Member
Re: Sort DataGrid
Do you download and look at my solution?
This is what I have...
VB Code:
Private Sub DataBind1()
OleDbDataAdapter1.Fill(DataSet11)
DataGrid1.DataBind()
End Sub
Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, _
ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs)_
Handles DataGrid1.PageIndexChanged
DataGrid1.CurrentPageIndex = e.NewPageIndex
DataBind1()
End Sub
Private Sub DataGrid1_SortCommand(ByVal source As Object, _
ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) _
Handles DataGrid1.SortCommand
DataView1.Sort = e.SortExpression + " ASC"
DataGrid1.DataSource = DataView1
DataBind1()
End Sub
I didn't notice, but I had DatGrid1.Databind(), which is wrong. It should of been just DataBind()... that is where my data is bound to grid.
So, now the data stays bound to grid, but doesn't sort.
See at.. http://www.ourwebzone.com/codebase/index.aspx
Thanks
Last edited by epixelman; Oct 26th, 2005 at 06:07 AM.
-
Oct 27th, 2005, 10:50 AM
#7
Thread Starter
Fanatic Member
Re: Sort DataGrid

.
-
Oct 27th, 2005, 11:46 AM
#8
Addicted Member
Re: Sort DataGrid
Not too sure, maybe its because you set the datasource of the datagrid in your html? Take that out and see what happens.
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
|
Click Here to Expand Forum to Full Width
|