Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have gridview, inside gridview a take column checkbox. Now I want if checkbox is checked then update database. Now I am not able to write code in which gridview event I write code.Please help me
Posted

You have to use the OnCheckChanged Event of the checkbox.

In the source of that event you state:
C#
CheckBox cb = (CheckBox)sender;
GridViewRow row =(GridViewRow)cb.NamingContainer;


In that case you kno in which row the checkbox was check3ed. You now know checkbox and teh row, so if you set the selectedindex to that row (row.RowIndex) and you use the DataNames in the gridview settings, you know what to update in your database
 
Share this answer
 
You can achieve this in following way:

1. add handler to call server side function(checkFunction) in which you write your code for database connection and query execution.
code for add handler
AddHandler CheckBox1.CheckedChanged AddressOf checkFunction

in checkFunction write database code for update records.in this you got checked checkbox id.

All the best.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900