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

Retrieving the value of a column in the row being updated

3 Answers 123 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Phani Musale
Top achievements
Rank 1
Phani Musale asked on 16 Mar 2010, 01:24 PM
Hi,

Is there a way by which I can retrive the value of a column of a row, in the Updating() event of the sql data source control? I am trying to set the parameters of the stored procedures on updating event. And the value of one of the parameters will be from one of the columns of the row being updated.

Thanks

3 Answers, 1 is accepted

Sort by
0
robertw102
Top achievements
Rank 1
answered on 16 Mar 2010, 02:48 PM
If it's automatically passed in the SqlDataSource's Update command, then I'm sure you can access it from the e.Command.Parameters list.

Like so:

object column1 = e.Command.Parameters["column1"].Value;

I hope that helps.
0
Phani Musale
Top achievements
Rank 1
answered on 16 Mar 2010, 03:05 PM
Thanks for the reply.
But sorry, it's seems that my question was not clear enough. HEre is the scenario:
- I have a radGrid
- It has Editmode as inline
- The grid has 4 columns, "email" being one of them
- On the grid I have  GridEditCommandColumn which allows me to edit and update each row.
- The grid is populated by a sql data source
- After editing, when I click Update, the Updating event of the sql datasource gets fired
- In here, I need to access the email field in the grid for row being updated.

I tried the way you suggested, but it is only for parameters in the sql datasource <UpdateParameters>  tag.

Any further help will be much appreciated

Thanks
0
Accepted
Veli
Telerik team
answered on 19 Mar 2010, 07:29 AM
Hi Phani,

If you add an update parameter for the Mail field in your SqlDataSource, and the Mail field is one of the updated fields in the item, I believe you can find the field value in the e.Command.Parameters collection.

If you do not want to do that, here is another approach:

string email = ((RadGrid1.EditItems[0] as GridEditableItem).EditManager.GetColumnEditor("Email") as GridTextBoxColumnEditor).Text;

The above snippet is used to find the value of a field named Email shown in a GridBoundColumn in RadGrid. The example accesses the first edited item in the grid, which is fine when you have a single editable item at a time.  If you enabled AllowMultiRowEdit="true", you will need to know which edited item in the EditItems collection is your item.

Regards,
Veli
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.
Tags
Grid
Asked by
Phani Musale
Top achievements
Rank 1
Answers by
robertw102
Top achievements
Rank 1
Phani Musale
Top achievements
Rank 1
Veli
Telerik team
Share this question
or