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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shaun KlineLead 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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.