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

Click event of Linkbutton in gridtemplatecolumn

1 Answer 289 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 13 Jan 2009, 06:56 PM
I've got a linkbutton in my grid which when I click it I want a Label in that row to toggle it's visiblity...

I tied the button to an event, and it is firing, but I have no way to get the row to set the visibility

Am I going about this the wrong way?

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 14 Jan 2009, 05:06 AM
Hello Steve,

Try the following code snippet for setting the visibility of label which is in a GridTemplateColumn.

ASPX:
<telerik:GridTemplateColumn UniqueName="Label"
<ItemTemplate> 
        <asp:Label ID="Label1" Text='<%# Bind("Country") %>' runat="server"> /asp:Label> 
</ItemTemplate> 
</telerik:GridTemplateColumn> 
         
<telerik:GridTemplateColumn UniqueName="linkbutton"
<ItemTemplate> 
        <asp:LinkButton Text="show/hide" runat="server" ID="linkbutton1" onclick="linkbutton1_Click"></asp:LinkButton> 
</ItemTemplate> 
</telerik:GridTemplateColumn>         

CS:
protected void linkbutton1_Click(object sender, EventArgs e) 
    LinkButton link = (LinkButton) sender; 
    Label lbl = (Label) link.NamingContainer.FindControl("Label1"); 
    lbl.Visible = !lbl.Visible; 

Thanks,
Shinu.
Tags
Grid
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
Shinu
Top achievements
Rank 2
Share this question
or