Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
Nagul #1
Re: PreRender Datagrid Header
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 !!!Nagul Guest
-
adding sub group headers dynamically for datagrid in prerender
problem.. the code creates a header row when i see the rendered hTML but it is not creating the table cell inside the row. ie. it is rendering as... -
change HeaderText of DataGrid in PreRender().
I need change HeaderText of DataGrid in PreRender(). But it seems doesn't work. The code example like this: Protected Overrides Sub... -
Removing the datagrid header.....
How to remove the datagrid header display ? Which property I should change ? Thanks -
datagrid header
Is it possible to have an overall header that spans across all columns? An example would be a class schedule for student Ben. |Ben |English ... -
DataGrid header and <TH>
Hello Vaclav, You might use the HeaderStyle of the DataGrid which will create Th on the client side. You can also attach style attribute to this...



Reply With Quote

