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

row index of selected row

6 Answers 104 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Erin
Top achievements
Rank 1
Erin asked on 23 Dec 2013, 01:19 PM
Hi,
 how can i get the row index of selected row.

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Dec 2013, 01:28 PM
Hi Erin,

Below is the code I tried to get the selected row index on a button click, please try and let me know if any concern.

C#:
protected void Button1_Click(object sender, EventArgs e)
{
  foreach (GridDataItem ditem in RadGrid1.SelectedItems)
  {
      int index = ditem.ItemIndex;  // Selected row index      
  }
}

Thanks,
Princy
0
Ryan
Top achievements
Rank 1
answered on 26 Dec 2013, 03:02 PM
Hi princy.   

How can I change the row color here? 
0
Ryan
Top achievements
Rank 1
answered on 26 Dec 2013, 03:05 PM
I need to change the color of an unselected row.. I didn't have selection property set for the grid view 
0
Shinu
Top achievements
Rank 2
answered on 26 Dec 2013, 03:13 PM
Hi Ryan,

I guess you want to set the back-color of rows, below is a sample code snippet that i tried to set back-color on button click.

C#:
protected void Button1_Click(object sender, EventArgs e)
 {
     foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
     {
         item["ColumnUniqueName"].BackColor = Color.Red;
     }
 }

Thanks,
Shinu
0
Ryan
Top achievements
Rank 1
answered on 27 Dec 2013, 08:20 AM
Hi, 
Thanks for the response..  is it possible with by setting the color in css .
0
Shinu
Top achievements
Rank 2
answered on 27 Dec 2013, 08:31 AM
Hi Ryan,

Please try the following code snippet:

C#:
protected void Button1_Click(object sender, EventArgs e)
{
    foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
 {
     item["OrderID"].CssClass = "color";
 }
}

CSS:
<style type="text/css">
  .color
  {
      background-color: Red;
  }
</style>

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