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

Accessing row in Datagrid

4 Answers 111 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ammar
Top achievements
Rank 2
Ammar asked on 03 May 2008, 08:49 AM
Hi All,
    
    In asp, usually, we can say myGridView.selectedRow.cells.item(1).text, howver, what's the equivalent expression for ajaxgrid.

Thx in advanced

4 Answers, 1 is accepted

Sort by
0
Kiara
Top achievements
Rank 1
answered on 04 May 2008, 04:08 PM
Ammar, I think that the equivalent syntax with the Telerik RadGrid is:

CType(MyRadGrid.SelectedItems(0), GridDataItem)("<MyColumnUniqueName>").Text

How to access data in RadGrid rows you can find out from these sources:

http://www.telerik.com/DEMOS/ASPNET/Prometheus/Grid/Examples/Programming/AccessingCellsAndRows/DefaultCS.aspx
http://www.telerik.com/help/radcontrols/aspnet%2Dajax/?grdAccessingCellsAndRows.html

Kiara


0
Princy
Top achievements
Rank 2
answered on 05 May 2008, 10:35 AM
Hi Ammar,

I tried with the following line of code in a Button click event to access the selected cell text.

CS:
  protected void Button1_Click(object sender, EventArgs e)  
    {  
        string selecteditem = RadGrid1.SelectedItems[0].Cells[1].Text;  
 
   } 

Thanks
Princy.
0
Ammar
Top achievements
Rank 2
answered on 05 May 2008, 04:44 PM
Hi My friends

    I rtied both, but it always, says index out of range.
0
Kiara
Top achievements
Rank 1
answered on 06 May 2008, 11:22 AM
This can happen if you do not have selected rows in the grid since the SelectedItems collection is empty. Do you handle this case, what you found when you debugged your code?

Kiara
Tags
Grid
Asked by
Ammar
Top achievements
Rank 2
Answers by
Kiara
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Ammar
Top achievements
Rank 2
Share this question
or