TemplateColumn

Discussion in 'ASP .Net' started by Dave, Oct 2, 2004.

  1. Dave

    Dave Guest

    Hello.
    Can anybody explain me how to use TemplateColumn?
     
    Dave, Oct 2, 2004
    #1
    1. Advertising

  2. Dave

    Greg Burns Guest

    Basically you remove your <Asp:BoundColumn> columns and replace them with
    <Asp:TemplateColumn> columns. A template column defines explicity what is
    shown when in Item mode (not in edit mode) and when in Edit mode.

    Normally every TemplateColumn has at the minimum an ItemTemplate and an
    EditItemTemplate. If you ommit the EditItemTemplate you can make a column
    read-only when in edit mode.

    Here is a quick sample:

    <ASP:DataGrid runat=server ... >
    <COLUMNS>
    <ASP:TEMPLATECOLUMN>
    <ITEMTEMPLATE>
    <asp:label id="lblItemCharge" Runat="server" CssClass="ChargeItem"><%#
    Server.HtmlEncode(Container.DataItem("Charge")) %></asp:label>
    </ITEMTEMPLATE>

    <EDITITEMTEMPLATE>
    <asp:TextBox id=txtEditCharge Runat="server" CssClass="ChargeInput"
    Text='<%# Container.DataItem("charge") %>' MaxLength="10"></asp:TextBox>
    </EDITITEMTEMPLATE>
    </ASP:TEMPLATECOLUMN>
    <ASP:TEMPLATECOLUMN>
    repeat blah blah
    </ASP:TEMPLATECOLUMN>
    </COLUMNS>
    </Asp:DataGrid>

    HTH,
    Greg

    "Dave" <> wrote in message
    news:...
    > Hello.
    > Can anybody explain me how to use TemplateColumn?
    >
     
    Greg Burns, Oct 3, 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. Bob
    Replies:
    0
    Views:
    615
  2. Nus Pieds

    TemplateColumn CheckBox

    Nus Pieds, Jul 16, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    381
    Nus Pieds
    Jul 16, 2003
  3. Edward

    TemplateColumn Width

    Edward, Nov 21, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,226
    S. Justin Gengo
    Nov 21, 2003
  4. Maziar Aflatoun

    TemplateColumn with multiple parameters

    Maziar Aflatoun, Jan 3, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    398
  5. Solomon Shaffer

    CommandArgument in TemplateColumn

    Solomon Shaffer, Jan 16, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    699
    Solomon Shaffer
    Jan 16, 2004
Loading...

Share This Page