RadGrid for ASP.NET

Getting cell values for selected rows client side Send comments on this topic.
Selecting grid items > How-to > Getting cell values for selected rows client side

Glossary Item Box

There are various cases in which you would like to retrieve values for column cells (after row selection) for further processing. This is pretty intuitive task which can be accomplished with the GetCellByColumnUniqueName client side method (part of the client-side API of Telerik RadGrid). This function receives two parameters (row object and the UniqueName of a column) and will return as a result the cell from the grid table which corresponds to the row and column name parameters.
To visualize the conventions for client-side cell value access we are providing code snippets in the next section. Note that they represent two possible implementations: getting the cell content on row select (wiring the RowSelected event of the grid) and on button click (the button is placed outside the grid).  The program logic supports multi-row selection as well.

 

ASPX/ASCX Copy Code
<script type="text/javascript">
var grid;

function RowSelected(rowObject)
{
  var selRow = this.GetCellByColumnUniqueName(rowObject,"ContactName");
  //here selRow.innerHTML will hold the value for the selected row contact name
}
function GetSelectedNames()
{
  for (var i = 0; i
< grid.MasterTableView.SelectedRows.length; i++)
  {
 var
curRow = grid.MasterTableView.GetCellByColumnUniqueName(grid.MasterTableView.SelectedRows[i], "ContactName");
 
//here curRow.innerHTML will hold the value for the selected rows contact names
  }
}
function GridCreated()
{
  
grid = this;
}
<
/script><rad:RadGrid id="RadGrid1" runat="server" AllowMultiRowSelection="True">
<ClientSettings>
   
<Selecting AllowRowSelect="True"></Selecting>
   
<ClientEvents OnGridCreated="GridCreated" OnRowSelected="RowSelected"></ClientEvents>
</ClientSettings>
</
rad:RadGrid>
<
INPUT onclick="GetSelectedNames();" type="button" value="Get selected rows contact names">