Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
Michael Combs #1
LinkButton in Page Footer problem
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
Michael Combs Guest
-
Problem with LinkButton and AddAttributesToRender
Hi, I'm trying to design a custom LinkButton. It inherits LinkButton as I need the implementation of the Click event (and I don't know how to... -
Page #s in Footer - change the start number? How?
I'd like the page numbers that appear in the footer to start at a number other than 1. I can see easily how to do this for the PDF pages (on the... -
Need footer at page bottom, not just below content.
Hi to all. What would be the procedure for having a footer that shows up at the bottom of the users browser as opposed to just being right below... -
Page Footer
Darrell tat wo schreiben: With something like PHP or SSI (Server Side Includes). Try to rename the main file to *.shtml so that the server... -
LinkButton and page error in datagrid
A LinkButton in a datagrid opens a new window, when clicked. Then clicking on the next page number in the datagrid raises the following error: ... -
Michael Combs #2
Re: LinkButton in Page Footer problem
I've discovered that the code in my prerender event is causing the problem.
I am adding a 'super' header to my datagrid in the prerender event. I'm
creating a new DataGridItem, adding a new cell which contains a LinkButton.
I'm just displaying some text across the top of my datagrid with a 'Home'
button.
The problem is that each click of the button (or any other postback to the
grid) causes the data rows(grid bound to dataview) to offset by 1 row. More
simply put, it appears that a blank row is being adding to the top of the
list of data rows. This blank row is inserted below the header I add but
above the rest of the data rows. I've included the source of my prerender
event below. The statement that causes the offset is
grid.Controls(0).Controls.AddAt.. It appears that this statement is
incrementing some starting offset in the grid that is being maintained in
the viewstate. Anyone have any ideas on a solution?
Private Sub grid_PreRender(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles grid.PreRender
Dim di As DataGridItem = New DataGridItem(0, 0, ListItemType.Header)
Dim cell As TableCell = New TableCell()
di.ID = "header"
di.CssClass = "pager"
' page cell
cell.ColumnSpan = 1
di.Cells.Add(cell)
' home cell
cell = New TableCell()
cell.HorizontalAlign = HorizontalAlign.Right
cell.ColumnSpan = grid.Columns.Count - 1
cell.Text = "<a href=ProvAudit.asp>Home</a>"
di.Cells.Add(cell)
' adding a header above the top pager causes the pager
' to become visible regardless of intention
If grid.PagerStyle.Position = 1 OrElse _
grid.PagerStyle.Position = 2 OrElse _
Not grid.AllowPaging Then
grid.Controls(0).Controls.AddAt(0, di)
Else
grid.Controls(0).Controls.AddAt(1, di)
End If
End Sub
Michael Combs
Michael Combs Guest



Reply With Quote

