M
Michael Combs
I am modifying the paging ListItem footer in a datagrid in the ItemCreated
event. I'm adding another cell in which I place a 'Show All' LinkButton. So
far so good. The problem is that when the LinkButton is clicked and the page
is rendered again the grid renders one less row each time. Continually
clicking the button eventually shrinks the grid to having zero rows. I have
no code in the ItemCommand event of the datagrid and do not have a separate
LinkButton Click event handler. The ItemCreated code is below. Anyone have
any ideas?
Thanks,
Michael
Private Sub grid_ItemCreated(ByVal sender As System.Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles grid.ItemCreated
If e.Item.ItemType = ListItemType.Pager Then
Dim cell As TableCell
Dim pagerRow As TableCellCollection = e.Item.Cells
Dim pagerCell As TableCell = pagerRow(0)
Dim pageCounter As TableCell = New TableCell()
Dim showall As LinkButton = New LinkButton()
pagerCell.ColumnSpan = pagerCell.ColumnSpan - 1
pageCounter.HorizontalAlign = HorizontalAlign.Right
pageCounter.BorderStyle = BorderStyle.None
showall.ID = "ShowAll"
If _showall Then
showall.Text = "Show Pages"
Else
showall.Text = "Show All"
End If
'AddHandler showall.Click, AddressOf ShowAll_Click
pageCounter.Controls.Add(showall)
pagerRow.AddAt(1, pageCounter)
End If
End Sub
event. I'm adding another cell in which I place a 'Show All' LinkButton. So
far so good. The problem is that when the LinkButton is clicked and the page
is rendered again the grid renders one less row each time. Continually
clicking the button eventually shrinks the grid to having zero rows. I have
no code in the ItemCommand event of the datagrid and do not have a separate
LinkButton Click event handler. The ItemCreated code is below. Anyone have
any ideas?
Thanks,
Michael
Private Sub grid_ItemCreated(ByVal sender As System.Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles grid.ItemCreated
If e.Item.ItemType = ListItemType.Pager Then
Dim cell As TableCell
Dim pagerRow As TableCellCollection = e.Item.Cells
Dim pagerCell As TableCell = pagerRow(0)
Dim pageCounter As TableCell = New TableCell()
Dim showall As LinkButton = New LinkButton()
pagerCell.ColumnSpan = pagerCell.ColumnSpan - 1
pageCounter.HorizontalAlign = HorizontalAlign.Right
pageCounter.BorderStyle = BorderStyle.None
showall.ID = "ShowAll"
If _showall Then
showall.Text = "Show Pages"
Else
showall.Text = "Show All"
End If
'AddHandler showall.Click, AddressOf ShowAll_Click
pageCounter.Controls.Add(showall)
pagerRow.AddAt(1, pageCounter)
End If
End Sub