Hi,
Could someone please help me with sample code on how to
programmatically add a column of checkboxes to data displayed in a
Gridview? And how to find whether the checkbox is checked or not on
postback.
Thanks in advance.
Saimvp - 29 Apr 2008 07:10 GMT
hi and hello good day.
you can try this codes:
//declare it to the top
DataGridViewCheckBoxColumn mygrid = new DataGridViewCheckBoxColumn();
private void Form1_Load(object sender, EventArgs e)
{
mygrid.HeaderText = "Status";
mygrid.Name = "status";
grid.Columns.Insert(0, mygrid);
}
private void grid_CellMouseClick(object sender,
DataGridViewCellMouseEventArgs e)
{
if (mygrid.ThreeState == false)
{MessageBox.Show("check");}
else
{MessageBox.Show("uncheck");}
}
I hope it can help u

Signature
To be Happy is To be Yourself
> Hi,
>
[quoted text clipped - 4 lines]
>
> Thanks in advance.
d.s.stevenson@gmail.com - 30 Apr 2008 02:14 GMT
Thanks for your help.. I get the following error when i try the code
you supplied.
cannot convert from 'System.Windows.Forms.DataGridViewCheckBoxColumn'
to System.Web.UI.WebControls.DataControlField'
code:
DataGridViewCheckBoxColumn mygrid = new DataGridViewCheckBoxColumn();
mygrid.HeaderText = "Status";
mygrid.Name = "status";
grdAdv.Columns.Insert(0, mygrid); //Error produced on this line.
Any ideas?
Ignacio Machin ( .NET/ C# MVP ) - 29 Apr 2008 16:01 GMT
On Apr 28, 10:50 pm, d.s.steven...@gmail.com wrote:
> Hi,
>
[quoted text clipped - 4 lines]
>
> Thanks in advance.
Hi,
Take a look at ITemplate