Changing text of a label inside a control...

Discussion in 'ASP .Net Datagrid Control' started by bredal Jensen, Apr 22, 2004.

  1. Hello there,

    I need to change the text of a label inside a datagrid.
    The label is part of an <EditItemTemplate >

    Can anyone post code of how to do this?

    Many thanks
     
    bredal Jensen, Apr 22, 2004
    #1
    1. Advertising

  2. bredal Jensen

    Juliet Choy Guest

    You have to give an ID to your Label Control, say "Label1", then you can
    change your text by using the OnItemDataBound event:

    private void DataGrid1_ItemDataBound(object sender,
    DataGridItemEventArgs e) {
    if(e.Item.ItemType == ListItemType.EditItem) {
    Label l = (Label)e.Item.Cells[colNum].FindControl("Label1");
    l.Text = "Your desired text";
    }
    }

    Hope this help you.
    Regards,
    Juliet Choy
    Hong Kong
    Microsoft MVP - ASP.NET

    bredal Jensen wrote:

    > Hello there,
    >
    > I need to change the text of a label inside a datagrid.
    > The label is part of an <EditItemTemplate >
    >
    > Can anyone post code of how to do this?
    >
    > Many thanks
    >
    >
     
    Juliet Choy, Apr 23, 2004
    #2
    1. Advertising

  3. Right , great help... Thanks a lot
    "Juliet Choy" <> wrote in message
    news:%...
    > You have to give an ID to your Label Control, say "Label1", then you can
    > change your text by using the OnItemDataBound event:
    >
    > private void DataGrid1_ItemDataBound(object sender,
    > DataGridItemEventArgs e) {
    > if(e.Item.ItemType == ListItemType.EditItem) {
    > Label l = (Label)e.Item.Cells[colNum].FindControl("Label1");
    > l.Text = "Your desired text";
    > }
    > }
    >
    > Hope this help you.
    > Regards,
    > Juliet Choy
    > Hong Kong
    > Microsoft MVP - ASP.NET
    >
    > bredal Jensen wrote:
    >
    > > Hello there,
    > >
    > > I need to change the text of a label inside a datagrid.
    > > The label is part of an <EditItemTemplate >
    > >
    > > Can anyone post code of how to do this?
    > >
    > > Many thanks
    > >
    > >
     
    bredal Jensen, Apr 23, 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. Henke
    Replies:
    1
    Views:
    641
    Henke
    May 5, 2004
  2. CSharpner
    Replies:
    0
    Views:
    1,048
    CSharpner
    Apr 9, 2007
  3. Dan
    Replies:
    2
    Views:
    449
  4. Rob Boger

    Iframe & Changing Parent Label Text.

    Rob Boger, Nov 4, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    250
    Rob Boger
    Nov 4, 2004
  5. Knut Krueger
    Replies:
    8
    Views:
    280
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page