This is a migrated thread and some comments may be shown as answers.

Is there any way to access a label in the Grid's CommandItemTemplate?

1 Answer 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Acadia
Top achievements
Rank 1
Acadia asked on 28 Aug 2008, 07:43 PM
As in:

<CommandItemTemplate>

<asp:Button runat="server" ID="btnUA" Text="Update All" CommandName="UpdateAll" CssClass="CommandButton" />

<asp:Label ID="lblUpdMsg" runat="server" ForeColor="Red"></asp:Label>

</CommandItemTemplate>


I want to be able to set the value of  lblUpdMsg in code behind but it isn't recognized.  is this possible?

Thanks!

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 29 Aug 2008, 04:15 AM
Hi Acadia,

Try accessing the label from the CommandItemTemplate in the ItemDataBound event as shown below.

CS:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if (e.Item is GridCommandItem) 
        { 
            GridCommandItem cmditm = (GridCommandItem)e.Item; 
            Label lbl = (Label)cmditm.FindControl("lblUpdMsg"); 
           // lbl.Text="CustomText";
        } 
    } 


Thanks
Shinu.
Tags
Grid
Asked by
Acadia
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or