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. Advertising

  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. 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. Gandalf
    Replies:
    0
    Views:
    479
    Gandalf
    Aug 10, 2003
  2. =?Utf-8?B?QWxlc3NhbmRybyBSb3NzaQ==?=

    Set Column Headertext

    =?Utf-8?B?QWxlc3NhbmRybyBSb3NzaQ==?=, Feb 27, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    330
    Martin Dechev
    Feb 27, 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,344
    Alvin Bruney [MVP]
    May 27, 2004
  4. Jeff
    Replies:
    8
    Views:
    505
  5. mg

    Set headertext in datagrid programatically

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

Share This Page