L
lac61675
Hi all,
I hope you can help me out on this one. I am creating a dynamic
datagrid within a user control. I have a function that builds columns
and formats the datagrid in Page_Init. I add the datagrid to a table
control dynamically in Page_Load.
When I build the columns, I set the first column in the control to be a
buttoncolumn as follows:
btc = New ButtonColumn()
btc.ButtonType = ButtonColumnType.PushButton
btc.Text = "Details"
btc.CommandName = "Details"
dg1.Columns.Add(btc)
After all columns are designed, I call a function that sets paging
Mode=NextPrev:
dg1.PagerStyle.Mode = PagerMode.NextPrev
dg1.PagerStyle.NextPageText = "Next >"
dg1.PagerStyle.PrevPageText = "< Previous"
The problem occurs when ItemCommand is fired during paging. It works
fine for "Next", but "Previous" is causing a problem -- the
e.CommandName returns "Details", which is the command name for the
button column.
Public Sub dg1_ItemCommand(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs) Handles dg1.ItemCommand
If e.CommandName <> "Page" Then
Dim tcButtonCol As TableCell = e.Item.Cells(0)
Dim tcDayCode As TableCell = e.Item.Cells(1)
DayCode = Trim(tcDayCode.Text)
RaiseEvent DGButtonClick(sender, e)
End If
End Sub
Does anyone why this is happening and how to resolve it? I have tried
e.Item.ItemIndex = -1, but "Previous" returns index 9 (and my grid
PageSize is 10). I've also tried e.CommandArgument, which returns
"Next" for Next, but empty string for Previous.
Thanks for your help,
Laura
I hope you can help me out on this one. I am creating a dynamic
datagrid within a user control. I have a function that builds columns
and formats the datagrid in Page_Init. I add the datagrid to a table
control dynamically in Page_Load.
When I build the columns, I set the first column in the control to be a
buttoncolumn as follows:
btc = New ButtonColumn()
btc.ButtonType = ButtonColumnType.PushButton
btc.Text = "Details"
btc.CommandName = "Details"
dg1.Columns.Add(btc)
After all columns are designed, I call a function that sets paging
Mode=NextPrev:
dg1.PagerStyle.Mode = PagerMode.NextPrev
dg1.PagerStyle.NextPageText = "Next >"
dg1.PagerStyle.PrevPageText = "< Previous"
The problem occurs when ItemCommand is fired during paging. It works
fine for "Next", but "Previous" is causing a problem -- the
e.CommandName returns "Details", which is the command name for the
button column.
Public Sub dg1_ItemCommand(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs) Handles dg1.ItemCommand
If e.CommandName <> "Page" Then
Dim tcButtonCol As TableCell = e.Item.Cells(0)
Dim tcDayCode As TableCell = e.Item.Cells(1)
DayCode = Trim(tcDayCode.Text)
RaiseEvent DGButtonClick(sender, e)
End If
End Sub
Does anyone why this is happening and how to resolve it? I have tried
e.Item.ItemIndex = -1, but "Previous" returns index 9 (and my grid
PageSize is 10). I've also tried e.CommandArgument, which returns
"Next" for Next, but empty string for Previous.
Thanks for your help,
Laura