Adding Headers to the Dynamically Created Datagrid..

Discussion in 'ASP .Net Web Controls' started by jayanth.vishnuvardhan@gmail.com, Sep 5, 2007.

  1. Guest

    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
    , Sep 5, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QW5kcmV3IFdpZWQ=?=

    Adding event handler for dynamically created controls

    =?Utf-8?B?QW5kcmV3IFdpZWQ=?=, Apr 19, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    1,382
    =?Utf-8?B?QmlsbCBCb3Jn?=
    Apr 25, 2004
  2. JezB
    Replies:
    2
    Views:
    4,855
  3. msimmons
    Replies:
    0
    Views:
    470
    msimmons
    Jul 16, 2009
  4. Anand
    Replies:
    0
    Views:
    200
    Anand
    Nov 16, 2004
  5. Replies:
    1
    Views:
    156
    marss
    Sep 6, 2007
Loading...

Share This Page