I am displaying a list of objects in a grid. One property of the object is a boolean value that I'd like to be able to allow the user to change simply checking/unchecking a checkbox. I want this to be a one-click solution - that is to say, I don't want them to have to select the row, go into edit mode, check the box, choose to save the records, etc. If the box gets checked, I want to update the record that it is bound to.
Simple enough I think, but going about this seems so problematic.
At first, I tried using a GridCheckBoxColumn. This correctly displays the value of the property, but is disabled. I learned that is because this will only enable if the row is in Edit mode. I added some code to the Pre_Render() event which causes every single row to be set to edit mode initially, but this looks pretty ugly - all the rows have dark lines on them, and I have to go back and explicitly set every other control in the row to ReadOnly so that they aren't editable.
My second attempt involved using a GridTemplateColumn, and an asp:CheckBox which is bound (Bind(MyProperty)) to the property. This also displays the value fine, but I'm not sure how to handle it past that. Checking the box doesn't seem to update the bound data? I figured maybe I could set AutoPostBack=True and call the OnChecked() function to set the value manually, but how do I get a reference to the row/item being checked?
Any help would be appreciated.
Simple enough I think, but going about this seems so problematic.
At first, I tried using a GridCheckBoxColumn. This correctly displays the value of the property, but is disabled. I learned that is because this will only enable if the row is in Edit mode. I added some code to the Pre_Render() event which causes every single row to be set to edit mode initially, but this looks pretty ugly - all the rows have dark lines on them, and I have to go back and explicitly set every other control in the row to ReadOnly so that they aren't editable.
My second attempt involved using a GridTemplateColumn, and an asp:CheckBox which is bound (Bind(MyProperty)) to the property. This also displays the value fine, but I'm not sure how to handle it past that. Checking the box doesn't seem to update the bound data? I figured maybe I could set AutoPostBack=True and call the OnChecked() function to set the value manually, but how do I get a reference to the row/item being checked?
Any help would be appreciated.