I am trying to fix a datagrid that I made many months ago. On this datagrid, my intent was to have one function handle any event on the dg initially. This function was called switchboard, and it either handled the event immediately or redirected the event to the appropriate handler. It works okay except for the event that paginates.
Here is the html for the dg~
<asp:datagrid
id=DataGrid1 runat="server" OnSortCommand="SortEventHandler" OnItemCommand="mySwitchboard" Width="400px" Height="250px" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" BackColor="White" CellPadding="4" DataSource="<%# DataSet11 %>" DataMember="audit_Location" DataKeyField="locationid" AutoGenerateColumns="False" AllowPaging="True" PageSize="5" AllowSorting="True" >
Here is mySwitchboard~
Public Sub mySwitchboard(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)
Dim a As String = e.CommandName.ToString
Label1.Text = a
If a = "Page" Then
DataGrid1.CurrentPageIndex = e.NewPageIndex
DataGrid1.DataBind()
Return
End If
If a = "nextWebPage" Then
nextWebPage(e)
ElseIf a = "Edit" Then
editDataGridRow(e)
ElseIf a = "Cancel" Then
cancelEdit()
ElseIf a = "Update" Then
updateDataGridRow(e)
End If
End Sub
The blue line of doom is under e.NewPageIndex
So I need to either finish implementing the switchboard idea, or handle the pagination separately.
I will be happy to take your suggestions on either approach.
Here is the html for the dg~
<asp:datagrid
id=DataGrid1 runat="server" OnSortCommand="SortEventHandler" OnItemCommand="mySwitchboard" Width="400px" Height="250px" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" BackColor="White" CellPadding="4" DataSource="<%# DataSet11 %>" DataMember="audit_Location" DataKeyField="locationid" AutoGenerateColumns="False" AllowPaging="True" PageSize="5" AllowSorting="True" >
Here is mySwitchboard~
Public Sub mySwitchboard(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)
Dim a As String = e.CommandName.ToString
Label1.Text = a
If a = "Page" Then
DataGrid1.CurrentPageIndex = e.NewPageIndex
DataGrid1.DataBind()
Return
End If
If a = "nextWebPage" Then
nextWebPage(e)
ElseIf a = "Edit" Then
editDataGridRow(e)
ElseIf a = "Cancel" Then
cancelEdit()
ElseIf a = "Update" Then
updateDataGridRow(e)
End If
End Sub
The blue line of doom is under e.NewPageIndex
So I need to either finish implementing the switchboard idea, or handle the pagination separately.
I will be happy to take your suggestions on either approach.