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

Batch update selected rows from external form

3 Answers 97 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Zyguy
Top achievements
Rank 1
Zyguy asked on 09 Jul 2008, 02:02 PM
I have a set of Radcomboboxes, RadInputs, etc. outside of my Radgrid. For layout purposes they could not be placed inside the CommandItemTemplate.

I want the user to be able to update the DB with values in these external controls (price, category, etc.), for all currently selected rows in the Radgrid.

I have wired the following event to the Update button in the CommandItemtemplate, but it just seems to postback the grid without any update actually happening:

Protected Sub RadGrid1_UpdateCommand(ByVal source As ObjectByVal e As Telerik.Web.UI.GridCommandEventArgs) 
IF RadGrid1.SelectedItems.Count > 0 THEN 
For Each SelectedItem As GridEditableItem In RadGrid1.SelectedItems 
Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem) 
Dim formItem As GridEditFormItem = CType(e.Item,GridEditFormItem) 
Dim parentItem As GridDataItem = CType(formItem.ParentItem,GridDataItem) 
Dim strProductID As String = parentItem("ProductID").Text 
Dim strCategoryID As String = RadComboBoxBatchDescribeCat.SelectedValue 
Dim Price As String = RadComboBoxBatchDescribePrice.SelectedValue 
SqlHelper.ExecuteNonQuery(_connectionString, "Batch_Apply", strProductID,strCategoryID,Price) 
Next 
ELSE  
End if 
RadGrid1.Rebind() 
End Sub 


I am a little bit confused about whether the Griditems need to be in Editmode, but the point is I basically want the Griditems to -appear- readonly, because all the data update input is done in the external group of controls.

Thanks

3 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 11 Jul 2008, 08:25 AM
Hello Zyguy,

To see more information along the lines of the specified functionality, please refer to the following article.
I hope it gets you started properly.

Sincerely yours,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Zyguy
Top achievements
Rank 1
answered on 15 Jul 2008, 08:09 AM
Thanks, I have built a working model based off the code in the article you linked.

I am a bit concerned about how the data is populated by Javascript into the hidden field 'textbox0'. Is there any possibility for malicious users to tamper with this? In our case, the hidden field is storing  the primary key ID's of users records, so it would be very bad if they could alter these keys and input someone elses primary key numbers.

We are of course doing a check on the final DB update, however i'm just curious about the vulnerability of this method in general.

Thanks
0
Yavor
Telerik team
answered on 18 Jul 2008, 06:19 AM
Hi Zyguy,

Basically, you can always verify the user input. Alternatively, you can use a user control, to update the records, or the built-in editing capabilities of the control. In any case, since the example which I initially referred to, uses client side script to facilitate the updates, this represents a potential vulnerability. Yet another alternative would be to populate the controls via an Ajax callback, from server side code. The key fields may also never be exposed.
I hope this information helps.

Sincerely yours,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Zyguy
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Zyguy
Top achievements
Rank 1
Share this question
or