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

How to get the current non-selected row?

1 Answer 76 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bruce
Top achievements
Rank 1
Bruce asked on 17 Feb 2014, 05:57 PM
I have a grid where I am using an ItemTemplate column with a CheckBox for row selection. If one of the columns has a particular value the row should not be selected again and I disable the checkbox for that row in the ItemDataBound event. Another column in that same row has a long string value that I want to popup a form where I can format and display the string in a user friendly way. It was all working until I decided to disable the checkbox. Disabling the checkbox also diables the ability to select the row. Now when I try to get the value for the row it fails because RadGrid1.SelectedItems.Count is 0. Is there a way to get the index of the double clicked row, or leave selection of the row enabled?

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 18 Feb 2014, 06:21 AM
Hi Bruce,

You can get the clicked row in the server side without having to select row using EnablePostBackOnRowClick="true" and access it in the ItemCommand event as follows:

ASPX:
<ClientSettings EnablePostBackOnRowClick="true">               
</ClientSettings>

C#:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
  if (e.CommandName == "RowClick")
  {
    int index = e.Item.ItemIndex; // Get Index 
    string val = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["OrderID"].ToString();// Get DataKeyValue                  
  }
}
 
Or from the ClientSide on OnRowDblClick event you can try the following to get the Index:

JS:
<script type="text/javascript">
  function OnRowDblClick(sender, args) {
      var index = args._itemIndexHierarchical;       
  }
</script>

Thanks,
Princy
Tags
Grid
Asked by
Bruce
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or