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

[Solved] How to find Grid rowitem text

3 Answers 103 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mano srinivasan
Top achievements
Rank 1
Mano srinivasan asked on 06 Nov 2009, 01:29 PM
Hi,

I am using Radgrid for asp.net ajax control in my project.

i  am having button control within the item template, i need to fire click event where i should find the cilcked button's text value.

how to do that ..

pls give me the solution.

thanks,

mano.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 Nov 2009, 01:39 PM
Hello Mano,

You can follow the example given here to achieve the required:
aspx:
<telerik:GridTemplateColumn UniqueName="TemplateColumn"
       <ItemTemplate> 
            <asp:Button ID="Button1" runat="server" Text='<%#Eval("FirstName") %>' OnClick="Button1_Click" /> 
       </ItemTemplate> 
</telerik:GridTemplateColumn> 

c#:
 protected void Button2_Click(object sender, EventArgs e) 
    { 
        Button btn = (Button)sender;        
        GridDataItem dataItem = (GridDataItem)btn.NamingContainer; 
        string strtxt = dataItem["BoundColumnUniqueName"].Text; 
    } 

Thanks
Princy
0
Mano srinivasan
Top achievements
Rank 1
answered on 06 Nov 2009, 02:38 PM
Hi Princy,

i have used like this,

<

telerik:GridTemplateColumn UniqueName="LinkName">

 

 

<ItemTemplate>

 

 

<asp:LinkButton ID="linkfilm" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"UplaodName")%>'
OnClick "LinkButton1_Click"></asp:LinkButton>

 

 


in the code behind,

 

protected void LinkButton1_Click(object sender, EventArgs e)

 

{

 

LinkButton btn = (LinkButton)sender;

 

 

GridDataItem dataItem = (GridDataItem)btn.NamingContainer;

 

 

string strtxt = dataItem["LinkName"].Text;

 

 

}


but the string value is empty.

what should i do.

thanks,
mano
0
Princy
Top achievements
Rank 2
answered on 09 Nov 2009, 06:03 AM
Hi Mano,

To access the text of the button, you should be trying the following code:
c#:
protected void LinkButton1_Click(object sender, EventArgs e)  
    { 
        LinkButton btn = (LinkButton)sender;  
        string strtxt = btn.Text;  
    }  

Thanks
Princy.
Tags
Grid
Asked by
Mano srinivasan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Mano srinivasan
Top achievements
Rank 1
Share this question
or