Editing Gridview using Checkbox template field

Hi I am trying to edit a gridview using a checkbox template field. For this I have added a templatefield of checkbox. Now when I click the checkbox it goes to its event handler where I set the Gridview's Editindex = the rowIndex. The particular row for which the checkbox was clicked switches to the edit mode but the checkbox state does not persists, the checkbox still shows unchecked. When I again click the same checkbox, this time it persists and now when I uncheck the checkbox it successfully brings the gridviewrow out of the edit mode
Please find attached the aspx and aspx.cs files. they are not complete so they cannot be used as it is but it includes everything related to the problem.

Open in new window

Who is Participating?
Shaun KlineConnect With a Mentor Lead Software EngineerCommented:
A solution would be to add an EditItemTemplate for the checkbox template. This would have your checkbox checked when the grid is rebound to the datasource.
   <asp:CheckBox ID="chkBox_Edit" runat="server" AutoPostBack="true" OnCheckedChanged="chkBx_Edit_CheckChanged" Checked="true" />

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.