Hi. I have a RadGrid that will display some records from a database table (using an sqldatasource). The user can edit and add records as normal. However, there is one field (called "default") which has special conditions associated with it. For a given set of records, only one record should have default=true.
I want to set client select = true such that only one record can be selected at a time (which is easy to do on the RadGrid). Then in the commandItem I want to add a button for a custom command "SetDefault". I am happy doing all of that - no problems.
My question relates to the code behind for the custom command "SetDefault". I can see three ways of doing what I want and would appreciate any view/comment about the best solution. If I do it within the Grid I am not sure how best to implement it. Options I can see are:
1. in the code use a datacontext and then a program loop to modify each of the records (easy to do) and I then assume I will need to refresh the grid.
2. somehow use an sql update query to update all of the records necessary (I can write the sql update query but I don't know how to execute a query from code) and then again refresh the grid
3. somehow process the RadGrid from the code that implements the custom command. This will have to do a foreach (GridDataItem item in RadGrid1.Items) loop that then modifies the value of a column in the grid. Questions: do I need to put each item into edit mode? How do I reference a column from the code to modify it's value? What do I need to do to then save the modified value? I am concerned that this approach will be slower than either of the previous two options - hence my question
Does this make sense?
I want to set client select = true such that only one record can be selected at a time (which is easy to do on the RadGrid). Then in the commandItem I want to add a button for a custom command "SetDefault". I am happy doing all of that - no problems.
My question relates to the code behind for the custom command "SetDefault". I can see three ways of doing what I want and would appreciate any view/comment about the best solution. If I do it within the Grid I am not sure how best to implement it. Options I can see are:
1. in the code use a datacontext and then a program loop to modify each of the records (easy to do) and I then assume I will need to refresh the grid.
2. somehow use an sql update query to update all of the records necessary (I can write the sql update query but I don't know how to execute a query from code) and then again refresh the grid
3. somehow process the RadGrid from the code that implements the custom command. This will have to do a foreach (GridDataItem item in RadGrid1.Items) loop that then modifies the value of a column in the grid. Questions: do I need to put each item into edit mode? How do I reference a column from the code to modify it's value? What do I need to do to then save the modified value? I am concerned that this approach will be slower than either of the previous two options - hence my question
Does this make sense?