This is a migrated thread and some comments may be shown as answers.
Get selected row values when linkbutton clicked in a GridTemplateColumn
7 Answers 82 Views
This is a migrated thread and some comments may be shown as answers.
suresh kumar
Top achievements
Rank 1
suresh kumar asked on 20 May 2010, 10:59 AM
Hi,
I am facing with an issue.
I had a linkbutton in GridTemplateColumn, when i click this linkbutton i need to get all the values from that row.
thanks in advance.

Regards,
Suresh Kumar Udatha.

7 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 20 May 2010, 11:43 AM
Hello Suresh,

You can get reference to the GridDataItem using NamingContainer property of LinkButton and can access the value using ColumnUniqueName. Check out the following code snippet.

C#:
 protected void LinkButton1_Click(object sender, EventArgs e) 
    { 
        LinkButton btn = (LinkButton)sender; 
        GridDataItem item = (GridDataItem)btn.NamingContainer; 
        string name = item["ColumnUniqueName1"].Text;
    } 

Regards,
Shinu.
0
suresh kumar
Top achievements
Rank 1
answered on 20 May 2010, 03:47 PM
Hi Shanu,
Thanks for your valuable code. Your code really helped a lot.
Thankyou for your support once again.
Regards,
Suresh Kumar udatha.
0
Spiros
Top achievements
Rank 1
answered on 26 May 2014, 09:11 AM
Hi Shanu , I am facing a similar situation . I have places
                                            <telerik:GridTemplateColumn UniqueName="isoptianal" DataField="isoptianal">
                                                <ItemTemplate>
                                                    <asp:CheckBox ID="CheckBox1" AutoPostBack="true" OnCheckedChanged="CheckDisount_CheckedChanged" runat="server" />
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>

and When i Click on the checkbox i need to get the  <MasterTableView AutoGenerateColumns="False" ClientDataKeyNames="Id" DataKeyNames="Id"> .
Do you have any idea ?
0
Shinu
Top achievements
Rank 1
answered on 26 May 2014, 12:20 PM
Hi Spiros,

I guess you want to get the DataKeyNames value on the CheckChanged event. Please try the following code snippet.

C#:
protected void CheckDisount_CheckedChanged(object sender, EventArgs e)
{
 CheckBox chkDiscount = (CheckBox)sender;
 GridDataItem dataItem = (GridDataItem)chkDiscount.NamingContainer;
 //Get the DataKeyName
 string Id = dataItem.GetDataKeyValue("Id").ToString();
}

Thanks,
Shinu
0
Spiros
Top achievements
Rank 1
answered on 26 May 2014, 02:42 PM
Yes Thanks a lot , I find this solution and works fine.
I am very happy that we choose telerik insted of some other. company.
Cheers
0
Henry
Top achievements
Rank 1
answered on 23 Jun 2017, 03:11 PM
7 yeas later this is still the simplest way to obtain Grid values from RadGrids thanks Shinu
0
Ajay
Top achievements
Rank 1
answered on 21 Sep 2018, 06:50 AM

HI shinu,

i have 2 GridTempelate columns in my grid. On click the link button of 1 GridTempelate, i want the value of other GridTempelate button.

 

thanks in advance

Tags
Grid
Asked by
suresh kumar
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
suresh kumar
Top achievements
Rank 1
Spiros
Top achievements
Rank 1
Henry
Top achievements
Rank 1
Ajay
Top achievements
Rank 1
Share this question
or