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

Set command item text on page load

2 Answers 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris LaFrancis
Top achievements
Rank 1
Chris LaFrancis asked on 22 Apr 2010, 08:02 PM
I have a couple of labels in the commanditemtemplate that I need to set during the page load event. Is this possible to do on the server side with VB.net code?
Thank you for your help.
Chris

2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 22 Apr 2010, 08:46 PM
Hello Chris,

It is possible to access the labels on Page_PreRender
Protected Sub Page_PreRender(sender As Object, e As EventArgs) Handles Me.PreRender
    Dim citem As GridItem = RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)(0)
    Dim myLabel As Label = TryCast(citem.FindControl("Label1"), Label)
    myLabel.Text = "something"
End Sub

or Item_Created
Protected Sub RadGrid1_ItemCreated(sender As Object, e As GridItemEventArgs) Handles RadGrid1.ItemCreated
    If TypeOf e.Item Is GridCommandItem Then
        Dim myLabel As Label = TryCast(e.Item.FindControl("Label1"), Label)
        myLabel.Text = "something"
    End If
End Sub

Best regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Chris LaFrancis
Top achievements
Rank 1
answered on 23 Apr 2010, 03:18 PM
That worked great, thank you very much for the help.
Tags
Grid
Asked by
Chris LaFrancis
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Chris LaFrancis
Top achievements
Rank 1
Share this question
or