Adding Headers to the Dynamically Created Datagrid..

  • Thread starter jayanth.vishnuvardhan
  • Start date
J

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
 
M

marss

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top