S
sam
Hello Group,
Havent had luck posting it to
microsoft.public.dotnet.framework.aspnet.datagridcontrol group. Excuse
me for the cross posting.
I have a datagrid which needs to be split into multiple
pages when printing along with headers on every page. I came up with
this routine below which adds 2 rows - one with datagrid headers and
the other is also a headers which consists other related information.
The 2 rows(headers) needs to be inserted for every
iMaxLines(constant-say 40) lines. When I debug, the headers get
inserted at correct positions but when doing a databind to
the datagrid(dgWIP), the headers show up at the very top of the
datagrid.
Not quite sure how to insert the headers and still retain
the sortorder. The initial databind is done as the addheaderlines
function is called after a postback and I need to retain the
sortorder. The sort is
disabled after the intial databind. Still cant understand, why are the
2 inserted rows shifted to the top of
the datagrid.
Any help on this issue would be great!!
cODE:
Private Sub addHeaderLines(ByVal dt As DataTable, ByVal part As
Int16)
Dim drHeader, drBlank As DataRow
Dim count, repeatCount, upperBound As Integer
Dim dvWIP As DataView
dvWIP = dt.DefaultView
dgWIP.DataSource = dvWIP
dvWIP.Sort = Me.SortColumn & " " & Me.SortOrder
dgWIP.DataBind()
dgWIP.AllowSorting = False
repeatCount = iMaxLines
upperBound = dt.Rows.Count
count = 0
While count <= upperBound
' If count Mod iMaxLines = 1 And count > 1 Then
If repeatCount = 1 Then
drBlank = dt.NewRow
drHeader = dt.NewRow
If part = 3 Then
drBlank(2) = "hd1"
drHeader(2) = "hd2"
Else
drBlank(0) = "hd1"
drHeader(0) = "hd2"
End If
dt.Rows.InsertAt(drBlank, count)
dt.Rows.InsertAt(drHeader, count + 1)
'count += 1
upperBound += 2
repeatCount = iMaxLines
Else
repeatCount -= 1
End If
count += 1
End While
dgWIP.DataSource = dt ' headers get shifted here...
dgWIP.DataBind()
End Sub
Thanks a bunch,
Sam.
Havent had luck posting it to
microsoft.public.dotnet.framework.aspnet.datagridcontrol group. Excuse
me for the cross posting.
I have a datagrid which needs to be split into multiple
pages when printing along with headers on every page. I came up with
this routine below which adds 2 rows - one with datagrid headers and
the other is also a headers which consists other related information.
The 2 rows(headers) needs to be inserted for every
iMaxLines(constant-say 40) lines. When I debug, the headers get
inserted at correct positions but when doing a databind to
the datagrid(dgWIP), the headers show up at the very top of the
datagrid.
Not quite sure how to insert the headers and still retain
the sortorder. The initial databind is done as the addheaderlines
function is called after a postback and I need to retain the
sortorder. The sort is
disabled after the intial databind. Still cant understand, why are the
2 inserted rows shifted to the top of
the datagrid.
Any help on this issue would be great!!
cODE:
Private Sub addHeaderLines(ByVal dt As DataTable, ByVal part As
Int16)
Dim drHeader, drBlank As DataRow
Dim count, repeatCount, upperBound As Integer
Dim dvWIP As DataView
dvWIP = dt.DefaultView
dgWIP.DataSource = dvWIP
dvWIP.Sort = Me.SortColumn & " " & Me.SortOrder
dgWIP.DataBind()
dgWIP.AllowSorting = False
repeatCount = iMaxLines
upperBound = dt.Rows.Count
count = 0
While count <= upperBound
' If count Mod iMaxLines = 1 And count > 1 Then
If repeatCount = 1 Then
drBlank = dt.NewRow
drHeader = dt.NewRow
If part = 3 Then
drBlank(2) = "hd1"
drHeader(2) = "hd2"
Else
drBlank(0) = "hd1"
drHeader(0) = "hd2"
End If
dt.Rows.InsertAt(drBlank, count)
dt.Rows.InsertAt(drHeader, count + 1)
'count += 1
upperBound += 2
repeatCount = iMaxLines
Else
repeatCount -= 1
End If
count += 1
End While
dgWIP.DataSource = dt ' headers get shifted here...
dgWIP.DataBind()
End Sub
Thanks a bunch,
Sam.