Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Changing text of a label inside a control...

Reply
Thread Tools

Changing text of a label inside a control...

 
 
bredal Jensen
Guest
Posts: n/a
 
      04-22-2004

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


 
Reply With Quote
 
 
 
 
Juliet Choy
Guest
Posts: n/a
 
      04-23-2004
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
>
>

 
Reply With Quote
 
 
 
 
bredal Jensen
Guest
Posts: n/a
 
      04-23-2004
Right , great help... Thanks a lot
"Juliet Choy" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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
> >
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with changing text of label with javascript Dan ASP .Net 2 05-22-2007 04:11 PM
dll config and web.config and Label Expressions (binding label text to dll config settings) CSharpner ASP .Net 0 04-09-2007 09:00 PM
Changing text on a label based on drop down selected value shikarishambu ASP .Net Web Controls 0 12-16-2006 07:47 PM
Iframe & Changing Parent Label Text. Rob Boger ASP .Net Web Controls 0 11-04-2004 08:44 AM
Changing Text property on label from dynamic imagebutton Henke ASP .Net 1 05-05-2004 03:48 PM



Advertisments