Column Header with Variable

Discussion in 'ASP .Net Datagrid Control' started by Hai, Oct 11, 2004.

  1. Hai

    Hai Guest

    Dear gurus,

    Is it possible to specify the column header with variable?
    If I want to make headerText as Sales and Credit how do I do so?

    Thanks in Advance.
    Hai


    'Here the codes

    Dim s1,s2 as string
    s1 = "Sales"
    s2 = "Credit"

    <asp:DataGrid
    ID="mygrid1"
    AutoGenerateColumns="False"
    Runat="Server">
    <Columns>
    <asp:BoundColumn DataField="REPNAME" HeaderText="REPNAME" />
    <asp:BoundColumn DataField="month1" HeaderText=s1 />
    <asp:BoundColumn DataField="month2" HeaderText=s2 />
    <asp:BoundColumn DataField="total" HeaderText="TOTAL" />
    </columns>

    </asp:DataGrid>
     
    Hai, Oct 11, 2004
    #1
    1. Advertising

  2. the header text is handled the same as an ordinary cell in either the
    itemdatabound or itemcreated event handler. test the cell contents first to
    make sure you have the right cell
    if(listitemtype.header == e.item.type)
    //do something

    roughly

    --
    Regards,
    Alvin Bruney
    [ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
    Got tidbits? Get it here... http://tinyurl.com/27cok
    "Hai" <> wrote in message
    news:...
    > Dear gurus,
    >
    > Is it possible to specify the column header with variable?
    > If I want to make headerText as Sales and Credit how do I do so?
    >
    > Thanks in Advance.
    > Hai
    >
    >
    > 'Here the codes
    >
    > Dim s1,s2 as string
    > s1 = "Sales"
    > s2 = "Credit"
    >
    > <asp:DataGrid
    > ID="mygrid1"
    > AutoGenerateColumns="False"
    > Runat="Server">
    > <Columns>
    > <asp:BoundColumn DataField="REPNAME" HeaderText="REPNAME" />
    > <asp:BoundColumn DataField="month1" HeaderText=s1 />
    > <asp:BoundColumn DataField="month2" HeaderText=s2 />
    > <asp:BoundColumn DataField="total" HeaderText="TOTAL" />
    > </columns>
    >
    > </asp:DataGrid>
    >
    >
     
    Alvin Bruney [MVP], Oct 12, 2004
    #2
    1. Advertising

  3. Hai

    Hai Guest

    Thank you Alvin
    Hai
    "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
    news:...
    > the header text is handled the same as an ordinary cell in either the
    > itemdatabound or itemcreated event handler. test the cell contents first

    to
    > make sure you have the right cell
    > if(listitemtype.header == e.item.type)
    > //do something
    >
    > roughly
    >
    > --
    > Regards,
    > Alvin Bruney
    > [ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
    > Got tidbits? Get it here... http://tinyurl.com/27cok
    > "Hai" <> wrote in message
    > news:...
    > > Dear gurus,
    > >
    > > Is it possible to specify the column header with variable?
    > > If I want to make headerText as Sales and Credit how do I do so?
    > >
    > > Thanks in Advance.
    > > Hai
    > >
    > >
    > > 'Here the codes
    > >
    > > Dim s1,s2 as string
    > > s1 = "Sales"
    > > s2 = "Credit"
    > >
    > > <asp:DataGrid
    > > ID="mygrid1"
    > > AutoGenerateColumns="False"
    > > Runat="Server">
    > > <Columns>
    > > <asp:BoundColumn DataField="REPNAME" HeaderText="REPNAME" />
    > > <asp:BoundColumn DataField="month1" HeaderText=s1 />
    > > <asp:BoundColumn DataField="month2" HeaderText=s2 />
    > > <asp:BoundColumn DataField="total" HeaderText="TOTAL" />
    > > </columns>
    > >
    > > </asp:DataGrid>
    > >
    > >

    >
    >
     
    Hai, Oct 12, 2004
    #3
    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. mlt
    Replies:
    2
    Views:
    907
    Jean-Marc Bourguet
    Jan 31, 2009
  2. hansiman

    Image in header column (not replacing column header text)

    hansiman, Feb 5, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    335
    hansiman
    Feb 7, 2004
  3. datagrid having row header and column header

    , Jul 13, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    197
  4. Teej
    Replies:
    2
    Views:
    336
  5. Replies:
    2
    Views:
    268
    jyoti
    Aug 19, 2006
Loading...

Share This Page