Re: PreRender Datagrid Header

Posted: 07-26-2003, 03:13 PM
thanks , i have figured out the problem

s_nagul2003@yahoo.co.in (Nagul) wrote in message news:<37e6a399.0307250241.ec325dc@posting.google.c om>...
> Hi All,
> I am creating a datagrid with custom header which has 2 rows , one
> is super header and other one is sub header. for example like this
> A B
> 1 2 A1 A2 B1 B2
>
> I have written a function in pre render event of the grid to
> create such kind of header. When the page is initially lods everything
> goes fine and i get the desired result but when the page is posted
> back and when it again gets rendered my grid goes ugly. The header
> comes to another line.
> Dim mycell As New TableCell()
> mycell.ColumnSpan = 3 'Set it to the colspan that you want
> mycell.Text = "Travel Agent"
> mycell.HorizontalAlign = HorizontalAlign.Center
>
> Dim mycell1 As New TableCell()
> mycell1.ColumnSpan = 4 'Set it to the colspan that you want
> mycell1.Text = "Head Office"
> mycell1.HorizontalAlign = HorizontalAlign.Center
>
> 'Set dg to the headeritem
> Dim dg As DataGridItem = sender.Controls(0).Controls(0)
> 'Make sure dg is a headeritem
> If dg.ItemType = ListItemType.Header Then
> 'Create a new headeritem for the columns that need a
> superheader
> Dim dgnew As New DataGridItem(0, 0, ListItemType.Header)
> Dim i As Integer = 0
> Dim bAdded As Boolean = False ' Have we added the
> superheader cell yet?
> 'Loop through each cell in the header item
> While i < dg.Cells.Count
> 'Check if the current cell needs to be moved to the
> lower Header(item)
> If dg.Cells(i).Text = "Commission" Or dg.Cells(i).Text
> = "VAT" Or dg.Cells(i).Text = "Reclaimed" Then
> 'Move the current cell to the lower header item
> dgnew.Cells.Add(dg.Cells(i))
> 'The .Add function here removes the cell from
> dg.Cells
> If Not bAdded Then
> 'Add the superheader cell
> dg.Cells.AddAt(i, mycell)
> bAdded = True
> i += 1
> Else
> 'Don't increase i because this time we
> actually reduced()
> 'the cell count by one, so now i points to the
> next
> 'cell
> End If
> ElseIf dg.Cells(i).Text = "HOCommissionPaid" Or
> dg.Cells(i).Text = "HOCommissionAmount" Or dg.Cells(i).Text =
> "HOVATOnCommission" Or dg.Cells(i).Text = "HOVATReclaimed" Then
> If dg.Cells(i).Text = "HOCommissionPaid" Then
> bAdded = False
> End If
> 'Move the current cell to the lower header item
> dgnew.Cells.Add(dg.Cells(i))
> 'The .Add function here removes the cell from
> dg.Cells
> If Not bAdded Then
> 'Add the superheader cell
> dg.Cells.AddAt(i, mycell1)
> bAdded = True
> i += 1
> Else
> 'Don't increase i because this time we
> actually reduced()
> 'the cell count by one, so now i points to the
> next
> 'cell
> End If
> Else
> 'This cell does not need a superheader cell, so
> make it span two rows
> dg.Cells(i).RowSpan = 2
> bAdded = False
> dg.Cells(i).VerticalAlign = VerticalAlign.Middle
> i += 1
> End If
> End While
> 'Add the new header item below the first one
> sender.Controls(0).Controls.AddAt(1, dgnew)
> End If
>
> Can anyone help please !!!
Reply With Quote

Responses to "Re: PreRender Datagrid Header"

 
LinkBack Thread Tools Search this Thread Display Modes
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it possible to repeat the DataGrid header on the top of each Printed page Raja ASP.NET Data Grid Control 1 09-27-2005 02:25 PM
DataGrid with image in the Column Header Mark ASP.NET Data Grid Control 1 07-17-2003 08:36 PM
Problem to Access web control on the DataGrid Header Prasad ASP.NET Data Grid Control 0 07-11-2003 11:28 AM
Datagrid not diplaying header text Atif Jalal ASP.NET Data Grid Control 1 07-08-2003 11:18 PM
how to check controls that on datagrid header Matt ASP.NET Data Grid Control 0 06-30-2003 02:55 PM