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

How to change Template (LinkButton) Column Text

3 Answers 34 Views
Grid
This is a migrated thread and some comments may be shown as answers.
YAVUZ
Top achievements
Rank 1
YAVUZ asked on 11 Nov 2008, 09:48 AM

Hi ,
I want to change LinkButton2 text dynamically. ("Update" to "blabla".)

<telerik:GridTemplateColumn UniqueName="TemplateColumn1">  
            <EditItemTemplate> 
                <asp:LinkButton  ID="LinkButton2" runat="server" CommandName="Update" Text="Update" CommandArgument='<%# Eval("CUSTOMERREF") %>'></asp:LinkButton> 
                &nbsp;<asp:LinkButton runat="server" CausesValidation="false" CommandName="Cancel"   
                    Text="Cancel"></asp:LinkButton> 
            </EditItemTemplate> 
            <ItemTemplate> 
                <asp:LinkButton runat="server" CausesValidation="false" CommandName="Edit"   
                    Text="Edit" ></asp:LinkButton> 
            </ItemTemplate> 
        </telerik:GridTemplateColumn> 
        <telerik:GridTemplateColumn UniqueName="TemplateColumn">  
            <ItemTemplate> 
                <asp:LinkButton runat="server" CausesValidation="false" CommandName="Delete"   
                    Text="Delete" CommandArgument='<%# Eval("CUSTOMERREF") %>'></asp:LinkButton> 
            </ItemTemplate> 
        </telerik:GridTemplateColumn> 

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 11 Nov 2008, 11:38 AM
Hello Yavuz,

Please test the approach shown below:

C#
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    GridEditFormItem item = e.Item as GridEditFormItem; 
    if (item != null && item.IsInEditMode) 
    { 
        LinkButton myButton = item["TemplateColumn1"].FindControl("LinkButton2"as LinkButton; 
        myButton.Text = "yourtext"
    } 

VB.NET
Protected Sub RadGrid1_ItemDataBound(ByVal sender As ObjectByVal e As GridItemEventArgs) 
    Dim item As GridEditFormItem = TryCast(e.Item, GridEditFormItem) 
    If item <> Nothing AndAlso item.IsInEditMode Then 
        Dim myButton As LinkButton = TryCast(item("TemplateColumn1").FindControl("LinkButton2"), LinkButton) 
        myButton.Text = "yourtext" 
    End If 
End Sub 

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
YAVUZ
Top achievements
Rank 1
answered on 11 Nov 2008, 12:36 PM
Thank you for your interest but ı want to learn;

All grid rows have delete and edit column. I want to change these columns display names when combobox selectedvalue changing. Your answer change only on edit form.
0
YAVUZ
Top achievements
Rank 1
answered on 11 Nov 2008, 01:17 PM

I find the answer... Thank you :)

 

protected void grdVehicles_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)  
 
{  
 
if (cmbStatus.SelectedValue == "2")  
 
{  
 
 
if (e.Item is GridDataItem)  
 
{  
 
GridDataItem data = (GridDataItem)e.Item;  
 
LinkButton lbl = (LinkButton)data["TemplateColumn1"].FindControl("LinkButton4");  
 
lbl.Text = "Label";  
 
}   
 
 
}  
 

Tags
Grid
Asked by
YAVUZ
Top achievements
Rank 1
Answers by
Daniel
Telerik team
YAVUZ
Top achievements
Rank 1
Share this question
or