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

get selected rows values

7 Answers 903 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mohsinjk jk
Top achievements
Rank 1
mohsinjk jk asked on 01 Sep 2010, 11:19 AM
Hi 

I am working on rad grid. i want to get selected rows values using   <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" /> this checkbox column. I have read following example but i could not able to get values of particular selected row.

http://demos.telerik.com/aspnet-ajax/grid/examples/client/selecting/defaultcs.aspx
 Please guide me how i can traverse grid items if any row selected using this telerik:GridClientSelectColumn. 

Regards
Mohsin JK

7 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 01 Sep 2010, 11:44 AM
Hi Mohsinjk,

To fetch the values from grid cells you can use the GetCellByColumnUniqueName(rowObject, columnName) method. Further information about that approach is available in Getting cell values for selected rows client side help topic.

Kind regards,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Princy
Top achievements
Rank 2
answered on 01 Sep 2010, 11:50 AM
Hello Mohsin,

The following code shows you how to traverse through each grid item in a button-click client event.

ASPX:
<input type="submit" value="Submit" id="Submit" onclick="ButtonClick();" />

Java Script:
<script type="text/javascript">
    function ButtonClick() {
        var grid = $find("<%=RadGrid1.ClientID %>");
        var MasterTable = grid.get_masterTableView();
        for (var i = 0; i < MasterTable.get_dataItems().lengt.length; i++)//traverse through each grid item
         {
            var row = MasterTable.get_dataItems()[i]; // accessing the row
         }
     }
</script>

if you want to traverse through each grid items when selecting the row itself, then try the same code in OnRowSelected client event.

Thanks,
Princy.
0
mohsinjk jk
Top achievements
Rank 1
answered on 01 Sep 2010, 12:08 PM
the following java script code is giving me error. by the way what is this "<%=RadGrid1.ClientID %>"
 
Can i do this functionality with java script ???
0
Shinu
Top achievements
Rank 2
answered on 01 Sep 2010, 12:54 PM
Hi Mohsinjk,


The client code is used to get reference to grid client object using the $find(id) method (shortcut for the findComponent() method) of the ASP.NET AJAX framework.

For more information, check out the documentation:
Getting RadGrid client object

Could you provide some more information about error/mark-up used so that I can help you better?


-Shinu.
0
mohsinjk jk
Top achievements
Rank 1
answered on 02 Sep 2010, 01:40 PM
sorry for again help... 

I don't want to use Java Script for gets the selected rows values.
I want to do this functionality using C#.net code behind file.

Please guide me how to I can get values of select rows using code behind C#.Net.

Regards
Mohsin JK
0
Pavlina
Telerik team
answered on 02 Sep 2010, 01:54 PM
Hello Mohsinjk,

To access cell values you need to use column unique names as presented in this topic from the grid online documentation:
http://www.telerik.com/help/aspnet-ajax/grdaccessingcellsandrows.html

All the best,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
1
Princy
Top achievements
Rank 2
answered on 02 Sep 2010, 02:02 PM
Hello Mohsin,

If you want to loop through the selected item from server side, then the follwoing code will help you. And use the ColumnUniqueName for accessing the cell values as mentioned by Pavlina in the previous reply.

C#:
protected void Button1_Click(object sender, EventArgs e)
   {
       foreach (GridDataItem item in RadGrid1.SelectedItems) // loop through each selected row
       {
           string name = item["FirstName"].Text;// get each cell value using ColumnUniqueName
       }
   }

Thanks,
Princy
Tags
Grid
Asked by
mohsinjk jk
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Princy
Top achievements
Rank 2
mohsinjk jk
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or