Click here to Skip to main content
15,895,538 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:

Anybody knows how to set up checkbox column in a dataGridView, after setting the dataGridView1.DataSource?

At first the datagridview does not have any column, so after setting the dataSource it will create column automatically, but I don't know how to automatically set the column to be checkbox type.

Thanks

Posted

Check out the first result:
http://lmgtfy.com/?q=asp.net+checkbox+gridview
Also, your problem is probably that you are autogenerating columns. Set it to false then create your columns manually. Look here for more information:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.autogeneratecolumns.aspx
Also, check out:
http://www.codeproject.com/KB/webforms/CheckBoxCommand.aspx
 
Share this answer
 
v2
First , Go to the datagridview column property and set the columntype to datagridviewcheckboxcolumn it adds the checkbox columns in to ur datagrid view,then add Rows as per u required u can use it for adding Rows--> DataGridview1.Rows.Add(no. of rows); //e.g (5)
 
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