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

[Solved] How to pass the value from RadGrid to the Stored Procedure

4 Answers 437 Views
Grid
This is a migrated thread and some comments may be shown as answers.
wilmos
Top achievements
Rank 1
wilmos asked on 19 Jul 2009, 08:55 AM
Dear all,

I am new to asp.net from Java. May i know how can i get the row value (CustID) when selected the row in RadGrid to pass it to the stored procedure to perform tasks (update or delete) ?

Many thanks.

Regards,
Wilmos.
 

4 Answers, 1 is accepted

Sort by
0
Adam Hubble
Top achievements
Rank 1
answered on 19 Jul 2009, 08:51 PM
Hi,

You need to set the DataKeyNames property of radGrid to the identity key for your records. So in your case you would set DataKeyNames="CustID". RadGrid also allows for comma delimited (and therefore multiple) datakeyvalues.

Controls like sqldatasource or objectdatasource can pick the id key up automatically if you set them to use the selected value of radgrid. In code you could access the selected value via gridIdname.SelectedValue

Hope this helps,
Matt
0
Shinu
Top achievements
Rank 2
answered on 20 Jul 2009, 05:34 AM
Hi Wilmos,

You may also refer the following code library submission which explains how to perform Update/Insert/Delete operations  in RadGrid with stored procedures and SqlDataSource control .
Update/Insert/Delete with stored procedures and SqlDataSource control

Regards
Shinu.
0
wilmos
Top achievements
Rank 1
answered on 21 Jul 2009, 01:52 AM
thanks Shinu and Matt Davis for your kind infor.

May i know what is the different DataKeyNames and Child DataKeyNames?

I will continue to try for the solution provided by Shinu.

Thanks again for your big help.

Regards,
Wilmos.

0
Princy
Top achievements
Rank 2
answered on 21 Jul 2009, 07:34 AM
Hello Wilmos,

I've not heard of a property such as the ChildDataKeyNames. Did you mean ClientDataKeyNames? Anyways, let me explain all that i know :)

If you want to set DataKeyNames for the child(detail) tables, then you can set the DataKeyNames property in the GridTableView tag of the DetailTables as shown below:
aspx:
<telerik:RadGrid ID="RadGrid" DataSourceID="SqlDataSource1" runat="server" GridLines="None"
   <MasterTableView DataKeyNames="ProductID">            
       <DetailTables> 
          <telerik:GridTableView DataSourceID="SqlDataSource2" DataKeyNames="OrderID">  

The DataKeyNames array can be used to fetch the primary key field values for grid items of the MasterTableView or a detail GridTableView, server-side.
Retrieving primary key field values for selected items

Whereas, the ClientDataKeyNames array can be used to fetch the key field values for grid items of the MasterTableView or a detail GridTableView, client-side.
Extracting key values client-side

Thanks
Princy.
Tags
Grid
Asked by
wilmos
Top achievements
Rank 1
Answers by
Adam Hubble
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
wilmos
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or