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

datakeyvalue on button click

1 Answer 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Savyo
Top achievements
Rank 1
Savyo asked on 12 Feb 2013, 08:30 AM
Hi
How can I get the datakeyvalue of the selected row on an external button click.

Savyo

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Feb 2013, 08:37 AM
Hi,

Please take a look into the following code snippet.

ASPX:
<ClientSettings >
   <Selecting  AllowRowSelect="true" />
 </ClientSettings>
<MasterTableView  DataKeyNames="CustomerID">

C#:
protected void Button1_Click(object sender, EventArgs e)
{
    foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
    {
       if (item.Selected)
       {
          string strKey = item.GetDataKeyValue("CustomerID").ToString();
       }
    }
}

Thanks,
Shinu.
Tags
Grid
Asked by
Savyo
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or