We recently converted a web project from 1.1 to 2.0 (VS 2005)
When some of our datagrids are rendered, the bottom row with the pager in it is pushed all the way over to the left, even though the code explicitly instructs it to go to the right.
When viewing the final source HTML that is delivered to the browser, it easy to spot that the final table cell (td) that holds the paging info is missing the colspan=x attribute, where x is the number of columns in the grid (table).
We haven't been able to spot a correlation as to when it happens on some grids and not others.
A cursory search for this on the InterWEB has provided one workaround, but no reason as to why it is happening. This is the fix I found:
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.Pager Then
Dim td0 As TableCell = e.Row.Cells(0)
Dim td1 As New TableCell
With td1
.ColumnSpan = 1
.Visible = False
End With
e.Row.Cells.AddAt(0, td1)
td0.ColumnSpan = GridView1.Columns.Count
End If
End Sub
I haven't tried it yet, hoping to find something more global.
Anyone else had this issue? Used a different workaround?
-
-
anyone?
-
I experience the same problem too.
I think it is a bug in DataGrid control in .NET 2.0. It happens when "AutoGenerateColumns" is set to true. GridView1.Columns.Count is always equal to the number of columns being added through designer, but NOT bound columns. Even in GridView1_PreRender, the GridView1.Columns.Count is incorrect. I think the ColSpan value is based on the GridView1.Columns.Count.
Though, I haven't found a better workaround except altering the last row's pager cell to have correct ColSpan value. -
Mar7in wrote:I experience the same problem too.
I think it is a bug in DataGrid control in .NET 2.0. It happens when "AutoGenerateColumns" is set to true. GridView1.Columns.Count is always equal to the number of columns being added through designer, but NOT bound columns. Even in GridView1_PreRender, the GridView1.Columns.Count is incorrect. I think the ColSpan value is based on the GridView1.Columns.Count.
Though, I haven't found a better workaround except altering the last row's pager cell to have correct ColSpan value.
I am thinking it might also be an issue because I am using a depracated 1.x DataGrid instead of the new 2.0 GridView.
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.