Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get rows of a Telerik RadGrid

I'm working on a RadGrid, and I want to access its rows but it seems it does not have a .Rows property.

Here's what I have tried until now:

enter image description here

How can I access rgCustomers's Rows collection? I want to add a button to each row.

like image 986
Mahdi Tahsildari Avatar asked Aug 04 '12 09:08

Mahdi Tahsildari


People also ask

How do I select a row in Radgrid programmatically?

To select multiple cells programmatically, set the IsSelected property of the desired cells to true . In this scenario, all four cells are added to the SelectedCells collection of RadGridView. You can access the instances of the selected cells in the SelectedCells collection by their index: C#

What is Telerik grid?

The GridView is part of Telerik UI for WinForms, a professional grade UI library with 140+ components for building modern and feature-rich applications.


1 Answers

According to Telerik's documentation,

"Each dynamic row in the grid represents a record from the specified data source. Dynamic rows are represented by the GridDataItem class (a descendent of GridItem).

Each GridTableView has a set of rows (the Items collection) of type GridDataItem."

So you want to use the Items collection of the grid, which is a collection of GridDataItems.

protected void btnLoad_Click(object sender, EventArgs e)
{
  rgCustomers.DataSource = odsCustomers;
  rgCustomers.DataBind();
  foreach (GridDataItem row in rgCustomers.Items)
  {
  }
}
like image 171
Daniel Avatar answered Sep 18 '22 18:09

Daniel