Problem with Datagrid Sorting

G

Guest

Hi. I have a webform datagrid which should sort whenever the column is
clicked. However, when the column is clicked no sorting occurs and the
datagrid (with the exception of the header) disappears. My code to perform
the datagrid sort is below. My datagrid's AllowSorting property is TRUE.
Could someone please let me know how I can fix this code so that the datagrid
sorts correctly? Thanks.

Private Sub DataGrid1_SortCommand(ByVal source As Object, _
ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) _
Handles DataGrid1.SortCommand

DataGrid1.DataSource = DsLogs.spLogsSelect.DefaultView.Sort
DsLogs.spLogsSelect.DefaultView.Sort = e.SortExpression
DataGrid1.DataBind()

End Sub


I've also read the following article to noavail
http://msdn.microsoft.com/library/d...code/html/vbtskcodesortingdatagridcontrol.asp
 
B

Brad Shook

In the datagrid Property builder did you select the sort expression for each
column?

Brad Shook
MrMike said:
Hi. I have a webform datagrid which should sort whenever the column is
clicked. However, when the column is clicked no sorting occurs and the
datagrid (with the exception of the header) disappears. My code to perform
the datagrid sort is below. My datagrid's AllowSorting property is TRUE.
Could someone please let me know how I can fix this code so that the datagrid
sorts correctly? Thanks.

Private Sub DataGrid1_SortCommand(ByVal source As Object, _
ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) _
Handles DataGrid1.SortCommand

DataGrid1.DataSource = DsLogs.spLogsSelect.DefaultView.Sort
DsLogs.spLogsSelect.DefaultView.Sort = e.SortExpression
DataGrid1.DataBind()

End Sub


I've also read the following article to noavail:
http://msdn.microsoft.com/library/d...code/html/vbtskcodesortingdatagridcontrol.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top