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

RadGrid Row select

4 Answers 194 Views
Grid
This is a migrated thread and some comments may be shown as answers.
kks
Top achievements
Rank 1
kks asked on 01 Jul 2008, 06:32 AM
hi telerik,

  I am using a radgrid, and i want to display all the column values to various text boxes and combo boxes while selecting a row from rad grid.
i am using a gridbutton column ( select ) to select the row.
can you tel me which is the fatest method to get the selected row vaules
and how ..? ( can you provide any example )
( if i dont want to use any javascript function )

expecting reply asap.
regards
kks

4 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 01 Jul 2008, 06:51 AM
Hello,

Additional information on a similar functionality is available in the following article. I hope it helps.

Best wishes,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
kks
Top achievements
Rank 1
answered on 01 Jul 2008, 08:12 AM
thanks Yavor.
  But my issue is i want to retrive all the column of selected row.
in the example which you mensioed above, will give only the column value which is assigned as datakeynames.
if my grid contain 30 column, i cant able to put all column names as DataKeyNames.

expecting your reply
0
Shinu
Top achievements
Rank 2
answered on 01 Jul 2008, 09:21 AM
Hi Kks,

Try accessing the columns from the selected row using the UniqueName property of the Column in the SelectedIndexChanged event of  the RadGrid as shown below.

CS:
protected void RadGrid2_SelectedIndexChanged(object sender, EventArgs e) 
    { 
        foreach (GridDataItem item in RadGrid1.MasterTableView.Items) 
        { 
            foreach(GridColumn col in RadGrid1.MasterTableView.RenderColumns ) 
            { 
              if (item.Selected) 
               { 
                   string strtxt = item[col.UniqueName].Text.ToString(); 
                } 
            } 
        } 
    } 


Thanks
Shinu.
0
Mike
Top achievements
Rank 1
answered on 07 Jul 2008, 04:01 PM
This will get you the selected row which is great.  Is there a way to get the row above and or below the selected row?

I am looking at what I was able to do with the GridView in ASP.NET and grab the index like this.

GridView gv = (GridView)sender;  
int index = int.Parse(e.CommandArgument.ToString());  
int Id = Convert.ToInt32(gv.DataKeys[index]["ID"]); 

With that I was able to do another index and get the row above it by subtracting by 1

int index2 = int.Parse(e.CommandArgument.ToString()) - 1;  
int Id2 = Convert.ToInt32(gv.DataKeys[index2]["ID"]); 

Is there a way I can do this with RadGrid?
Tags
Grid
Asked by
kks
Top achievements
Rank 1
Answers by
Yavor
Telerik team
kks
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Mike
Top achievements
Rank 1
Share this question
or