.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Imran Ghani
Sohaib Khalid

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

checkbox checked in GridView?

Posted By: Shweta     Posted Date: August 03, 2010    Points:2   Category :ASP.Net

I have a gridview which contains columns retreived from the database.i have in total 12 columns,in which 4 columns have checkbox's where ever there is a null in the database.i have done tht on the rowdatabound event of gridview dynamically by calling

CheckBox cb= new CheckBox();

now my question is,i want to check the boxes in the column cells and update those values in the database on button click.i also have a checkbox in the first column of the gridview created using an itemTemplate tag of gridview,so tht when we check the corresponding row's checkbox,the values in tht row shall be updated......any responses will be appreciated.


Author: Syed Shakeer Hussain             
Posted Date: August 04, 2010     Points: 5   

protected void GridViewCheck_Click(object sender, EventArgs e) 
for (int i = 0; i < Gridview1.Rows.Count; i++)
CheckBox chkb = (CheckBox)Gridview1.Rows[i].Cells[0].FindControl("chk");
if (chkb.Checked)
string id = Gridview1.Rows[i].Cells[2].Text;
//Write your Update Command here....
SqlCommand cmd=new SqlCommand("update tablename set name='"+textname.Text+"' where id='"+id+"'",conn);


Author: Clintonzz             
Posted Date: April 23, 2014     Points: 20   

This reminded me of the C# gridview checkbox column:


Hope this be helpful.

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend