| | |
to add checkbox in asp.net in gridview
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
1. right click on your DataGrid -->Property Builder -->Columns --> Template Column --> Apply --> Ok.
2. Right click again --> EidtTemplate --> choose Column you add --> drag CheckBox control from Toolbox and drop it in ItemTemplate field and if you need CheckBox in edit mode put another CheckBox control in EditItemTemplate field --> End Template Editing.
Code on the button:
2. Right click again --> EidtTemplate --> choose Column you add --> drag CheckBox control from Toolbox and drop it in ItemTemplate field and if you need CheckBox in edit mode put another CheckBox control in EditItemTemplate field --> End Template Editing.
Code on the button:
ASP.NET Syntax (Toggle Plain Text)
private void btn_Delete_Click(object sender, System.EventArgs e) { for(int i=0;i<dg_EditProduct.Items.Count;i++) { CheckBox chk = new CheckBox(); chk = (CheckBox)dg_EditProduct.Items[i].FindControl("chk_Delete"); if(chk.Checked) { DataTable myTable; myTable=(DataTable)Session["ProductTable"]; int ID_Delete = Convert.ToInt32( myTable.Rows[i]["ProductID"]); Str_Conn = ConfigurationSettings.AppSettings["Fashion"]; MyConn = new SqlConnection(Str_Conn); //Command to delete Product // SqlCommand cmd_DeleteProduct = new SqlCommand("dbo.DeleteProduct",MyConn); SqlCommand cmd_DeleteProduct = new SqlCommand("DeleteProduct",MyConn); cmd_DeleteProduct.CommandType = CommandType.StoredProcedure; SqlParameter ProductID_Delete = cmd_DeleteProduct.Parameters.Add("@ProductID",SqlDbType.Int); ProductID_Delete.Value = ID_Delete ; MyConn.Open(); dg_EditProduct.DataSource = myTable; cmd_DeleteProduct.ExecuteNonQuery(); MyConn.Close(); } } BindData(); // it is the function you use to bind data to datagrid on page load }
![]() |
Other Threads in the ASP.NET Forum
- Previous Thread: Opening Excel 2007 File using Asp.net Hangs
- Next Thread: How to add eventhandler..
| Thread Tools | Search this Thread |
.net 2.0 activexcontrol ajax alltypeofvideos appliances application asp asp.net bc30451 beginner bottomasp.net box browser button c# cac checkbox commonfunctions control dataaccesslayer database datagridview datagridviewcheckbox datalist deployment development dgv dialog dropdownlist dynamic dynamically edit embeddingactivexcontrol expose feedback fileuploader fill findcontrol flash form formatdecimal formview gridview gudi iis image javascript listbox login microsoft mobile mono mouse mssql news novell numerical opera panelmasterpagebuttoncontrols parent radio redirect registration relationaldatabases reportemail save schoolproject search security select sessionvariables silverlight smartcard smoobjects software sql-server sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos view vista visualstudio web webapplications webdevelopemnt webdevelopment webprogramming webservice xsl youareanotmemberofthedebuggerusers





