Programatically setting a HeaderTemplate HeaderText.

Discussion in 'ASP .Net Datagrid Control' started by Andy, May 25, 2004.

  1. Andy

    Andy Guest

    I am trying to set the header text of a datagrid at run time using the
    following code
    <asp:TemplateColumn HeaderText="">
    <HeaderTemplate>
    <asp:HyperLink id="hlLink"
    runat="server"></asp:HyperLink>="<%sHeadingString%>
    </HeaderTemplate>

    This doesn't work. And I can't seem to get to the object in code in
    the code behind page using something like
    dgLibraryView.Columns(0).hlLink.Text= sHeadingString

    Any ideas?

    Thanks.
     
    Andy, May 25, 2004
    #1
    1. Advertisements

  2. Andy

    Amar Guest

    You should override ItemCreated event of Grid and write everything you
    want at each cell

    protected override void OnItemCreated(DataGridItemEventArgs e) {

    if (e.Item.ItemType == ListItemType.Header){
    for(int i=0;i<e.Item.Cells.Count;i++){
    e.Item.Cells.Text = ........
    }
    }
    }


    (Andy) wrote in message news:<>...
    > I am trying to set the header text of a datagrid at run time using the
    > following code
    > <asp:TemplateColumn HeaderText="">
    > <HeaderTemplate>
    > <asp:HyperLink id="hlLink"
    > runat="server"></asp:HyperLink>="<%sHeadingString%>
    > </HeaderTemplate>
    >
    > This doesn't work. And I can't seem to get to the object in code in
    > the code behind page using something like
    > dgLibraryView.Columns(0).hlLink.Text= sHeadingString
    >
    > Any ideas?
    >
    > Thanks.
     
    Amar, May 26, 2004
    #2
    1. Advertisements

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. Richard Morse
    Replies:
    3
    Views:
    1,216
    Corey O'Mara
    Feb 7, 2004
  2. spammy
    Replies:
    0
    Views:
    465
    spammy
    May 21, 2004
  3. =?Utf-8?B?bWc=?=

    Set headertext in datagrid programatically

    =?Utf-8?B?bWc=?=, May 26, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,454
    Alvin Bruney [MVP]
    May 27, 2004
  4. sarj
    Replies:
    1
    Views:
    532
    jagadeesh
    Aug 11, 2004
  5. SimonH
    Replies:
    2
    Views:
    448
    William F. Robertson, Jr.
    Feb 10, 2005
  6. Dan
    Replies:
    0
    Views:
    552
  7. Jeff
    Replies:
    8
    Views:
    546
  8. mg

    Set headertext in datagrid programatically

    mg, May 26, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    211
    Kilic Beg
    May 27, 2004
Loading...