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

Set Label text in command item template?

2 Answers 122 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 17 Nov 2009, 04:33 PM
I have a label in the radgrid command item template I want to change the text of the label to the text of the selected radtabstrip tab. However I can't seem to find the label after it is placed in the template can anyone tell me how to set the text of the label when the tabstrip is clicked. Thanks for any help.

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 18 Nov 2009, 05:15 AM
Hello Robert,

Try the following code snippet in order to access the label placed in CommandItemTemplate and to set the text according to clicked tab.

CS:
 
    protected void RadTabStrip1_TabClick(object sender, RadTabStripEventArgs e) 
    {        
        GridCommandItem commandItem = (GridCommandItem)RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0]; 
        Label CommandLabel = (Label)commandItem.FindControl("Label1"); 
        CommandLabel.Text = e.Tab.Text.ToString(); 
    } 

Regards,
Shinu.
0
Robert
Top achievements
Rank 1
answered on 18 Nov 2009, 02:57 PM
Thanks it works great.

Here it is in VB if anyone else needs it
Protected Sub RadTabStrip1_TabClick(sender As Object, e As RadTabStripEventArgs)  
    Dim commandItem As GridCommandItem = DirectCast(RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)(0), GridCommandItem)  
    Dim CommandLabel As Label = DirectCast(commandItem.FindControl("Label1"), Label)  
    CommandLabel.Text = e.Tab.Text.ToString()  
End Sub 
Tags
Grid
Asked by
Robert
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Robert
Top achievements
Rank 1
Share this question
or