Home All Groups Group Topic Archive Search About

Adding Headers to the Dynamically Created Datagrid..

Author
5 Sep 2007 4:55 PM
jayanth.vishnuvardhan
Hi,

It would be great if someone suggests me on how to append "Header"
information for the dynamically created datagrids?

Here is my situation:-

I'm creating dynamic datagrids based on the data coming from database.
so far so good.. Then after that I need to create "Headers"
information like "payment","due date" etc.. information to each data
grid as headers.


I used Datagrid Prerender Method but it always adding the "headers" to
the last created dynamic datagrid. I'm not sure why it's doing like
tha, but i assume as it's Prerender it is only called once even though
we created dynamically.

Here is Code snippet:-

Protected Sub DynamicDGrid_PreRender(ByVal sender As Object, ByVal e
As System.EventArgs) Handles DynamicDGrid.PreRender

   Dim dgitem As New DataGridItem(0, 0, ListItemType.Header)

       Dim mycell12 As New TableCell
        mycell12.Text = "Next Payment"
        mycell12.HorizontalAlign = HorizontalAlign.Center
        mycell12.ColumnSpan = "2"
        mycell12.CssClass = "LoanSummaryGridHeadColor3"
        dgitem.Cells.Add(mycell12)

       Dim mycell7 As New TableCell
        mycell7.Text = "Most Recent Payment"
        mycell7.HorizontalAlign = HorizontalAlign.Center
        mycell7.ColumnSpan = "4"
        mycell7.CssClass = "LoanSummaryGridHeadColor2"
        dgitem.Cells.Add(mycell7)

    DynamicDGrid.Controls(0).Controls.AddAt(0, dgitem)

End sub

If you observe the above method the last statement says
"DynamicDGrid.Controls(0).Controls.AddAt(0, dgitem)".

Is this correct statement or am I Missing anything?

My o/p should be like this:-

       Header 1    Header 2
Col1    Col2    Col3    Col4    Col5    Col6
Data    data    data    Data    Data    data

       Header 1    Header 2
Col1    Col2    Col3    Col4    Col5    Col6
Data    data    data    Data    Data    data

Author
6 Sep 2007 6:51 AM
marss
On 5    , 19:55, jayanth.vishnuvard***@gmail.com wrote:
Show quote
> Hi,
>
> It would be great if someone suggests me on how to append "Header"
> information for the dynamically created datagrids?
>
> Here is my situation:-
>
> I'm creating dynamic datagrids based on the data coming from database.
> so far so good.. Then after that I need to create "Headers"
> information like "payment","due date" etc.. information to each data
> grid as headers.
>
> I used Datagrid Prerender Method but it always adding the "headers" to
> the last created dynamic datagrid. I'm not sure why it's doing like
> tha, but i assume as it's Prerender it is only called once even though
> we created dynamically.
>
> Here is Code snippet:-
>
>  Protected Sub DynamicDGrid_PreRender(ByVal sender As Object, ByVal e
> As System.EventArgs) Handles DynamicDGrid.PreRender
>
>    Dim dgitem As New DataGridItem(0, 0, ListItemType.Header)
>
>        Dim mycell12 As New TableCell
>         mycell12.Text = "Next Payment"
>         mycell12.HorizontalAlign = HorizontalAlign.Center
>         mycell12.ColumnSpan = "2"
>         mycell12.CssClass = "LoanSummaryGridHeadColor3"
>         dgitem.Cells.Add(mycell12)
>
>        Dim mycell7 As New TableCell
>         mycell7.Text = "Most Recent Payment"
>         mycell7.HorizontalAlign = HorizontalAlign.Center
>         mycell7.ColumnSpan = "4"
>         mycell7.CssClass = "LoanSummaryGridHeadColor2"
>         dgitem.Cells.Add(mycell7)
>
>     DynamicDGrid.Controls(0).Controls.AddAt(0, dgitem)
>
> End sub
>
> If you observe the above method the last statement says
> "DynamicDGrid.Controls(0).Controls.AddAt(0, dgitem)".
>
> Is this correct statement or am I Missing anything?
>
> My o/p should be like this:-
>
>            Header 1     Header 2
> Col1    Col2    Col3    Col4    Col5    Col6
> Data    data    data    Data    Data    data
>
>            Header 1     Header 2
> Col1    Col2    Col3    Col4    Col5    Col6
> Data    data    data    Data    Data    data

Look here
http://marss.co.ua/MergingGridViewHeaderColumns.aspx

Regards,
Mykola

AddThis Social Bookmark Button