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

Get ID of the row

2 Answers 254 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Adigard
Top achievements
Rank 1
Adigard asked on 10 Oct 2011, 03:55 PM
Greetings,

I have a buttonColumn in each row. I'd like to get the ID of the row when i click on it since i need it to make a query afterwards...

I tried to do it intuitively with e.Item.ClientID but it's not working
Thank you in advance

2 Answers, 1 is accepted

Sort by
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 10 Oct 2011, 04:58 PM
Hello,

protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
        {
            if (e.CommandName == "CommandName1")
            {
                GridDataItem item = e.Item as GridDataItem;
                int ID = Convert.ToInt32(item.GetDataKeyValue("ID"));
            }
        }
<MasterTableView DataKeyNames="ID">
<telerik:GridButtonColumn CommandName="CommandName1"></telerik:GridButtonColumn>

Let me know if any concern.

Thanks,
Jayesh Goyani
0
Adigard
Top achievements
Rank 1
answered on 10 Oct 2011, 05:35 PM
Perfectly working!
thanks
Tags
Grid
Asked by
Adigard
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Adigard
Top achievements
Rank 1
Share this question
or