Monday, August 16, 2010

Check box inside a datagrid(ASP.Net using C#)?

Hi Everyone,


My Datagrid has a TemplateColumn contains checkbox control and I set


its AutoPostback property to True. So that I can update database


straight after user Check or Uncheck the Checkbox.





I don't know how to capture the event when it postback after user has


check/uncheck a specific checkbox, in order to update my database.


I dont have a update button in the datagrid. My update button is outside the datagrid.





Your help will be greatly appreiciated.





Thanks a lotCheck box inside a datagrid(ASP.Net using C#)?
Interesting question. I believe this is the best way to handle it.





1- Post back the page (you have already done that since the AutoPostBack property of your checkbox is set to true





2- Determine which CheckBoxes are ';dirty'; through using the ';CheckedChanged'; property. The definitive way to determine whether a row has been dirtied is to handle the changed event for the checkbox in a row.





In the handler for these events, you maintain a list of the rows to be updated. Generally, the best strategy is to track the primary keys of the affected rows. For example, you can maintain an ArrayList object that contains the primary keys of the rows to update.





For more info check - Checking for Changed Items uner:


http://msdn2.microsoft.com/en-us/library鈥?/a>

No comments:

Post a Comment