5 Answers, 1 is accepted
Please try the following approaches:
1) Client side:
<ClientSettings> |
<Selecting AllowRowSelect="True" /> |
<ClientEvents OnRowSelected="RowSelected" /> |
</ClientSettings> |
<script type="text/javascript" language="javascript"> |
function RowSelected(sender, args) |
{ |
alert(args.get_itemIndexHierarchical()); |
} |
</script> |
2) Server side
<ClientSettings EnablePostBackOnRowClick="true"> |
<Selecting AllowRowSelect="True" /> |
</ClientSettings> |
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) |
{ |
if (e.CommandName == "RowClick") |
{ |
int selectedIndex = e.Item.ItemIndex; |
} |
} |
I hope this helps.
Kind regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

I was wondering if you had any thoughts about this. After a button in a row is clicked, I need to access a value from the row directly above it.
Thanks again.

Try out the following code to access a control in the previous row when the button in a row is clicked.
cs:
protected void Button_Click(object sender, EventArgs e) |
{ |
Button btn = (Button)sender; |
GridDataItem dataItem = (GridDataItem)btn.NamingContainer; |
int index = dataItem.ItemIndex; |
string strtxt = RadGrid1.MasterTableView.Items[index - 1]["ColumnUniqueName"].Text; |
} |
Thanks
Princy.

If
e.CommandName = "DeleteEmployee" Then
Dim
dataItem As Telerik.Web.UI.GridDataItem = CType(e.Item, Telerik.Web.UI.GridDataItem)
Dim itemValue As String = dataItem("EmployeeID").Text
Dim
selectedIndex As Integer = e.Item.ItemIndex
Dim
EmpID As String = itemValue
End If
What I was hoping to do is use this from the code you provided :
Dim
strtxt As String = RadGrid1.MasterTableView.Items(index - 1)("EmployeeID").Text
but it's not assigning the value to strtxt
C#
if (e.CommandName == "DeleteEmployee")
{
Telerik.Web.UI.GridDataItem dataItem = (Telerik.Web.UI.GridDataItem)e.Item;
string itemValue = dataItem("EmployeeID").Text;
int selectedIndex = e.Item.ItemIndex;
string EmpID = itemValue;
string strtxt = RadGrid1.MasterTableView.Items(index - 1)("EmployeeID").Text;
}
Thanks again

Can you try replacing the last line of your code i.e.,
Dim strtxt As String = RadGrid1.MasterTableView.Items(index - 1)("EmployeeID").Text |
with the following code strip
Dim strtxt As String = RadGrid1.MasterTableView.Items(selectedIndex - 1)("EmployeeID").Text |
and see if it helps.
Thanks
Princy.