1. I created a data grid with sorting enabled. This worked fine.
The following code is from my code-behind page
2. I then added a button column and a Click_Grid subroutine. This also worked fine. When I clicked on a
button
I redirected to a detail page. All great.
3. I then discovered that the sorting no longer worked. When I clicked on a header sort link, the
Click_Grid event occurred
and I got transferred to the detail page. I guess this is logical as I am clicking on the grid also. My
question is how do I differentiate the 2 events. TIA - Steve
'-------------------------------------------------------------------------------------------
From code-behind page
Sub Sort_Grid(ByVal Sender as Object, _
ByVal E as DataGridSortCommandEventArgs)
'---- Sorting code here
End Sub
Sub Click_Grid(ByVal sender As System.Object, _
ByVal e As DataGridCommandEventArgs)
' Pass the situationid in a querystring
Response.Redirect("listingdetails.aspx?situationid=" & E.Item.Cells(0).Text)
End Sub
'--------------------------
The datagrid definition from the aspx page:
<asp:DataGrid
id="dgSituations"
AllowSorting="True"
OnSortCommand="Sort_Grid"
AutoGenerateColumns="False"
CellPadding="3"
CellSpacing="0"
ShowFooter="False"
ShowHeader="True"
itemstyle-horizontalalign="center"
onitemcommand="Click_Grid"
runat="server"