473,394 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Programmatically adding a column of Checkboxes to Gridview

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.
Jun 27 '08 #1
3 6243
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

--
To be Happy is To be Yourself
"d.***********@gmail.com" wrote:
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.
Jun 27 '08 #2
On Apr 28, 10:50*pm, d.s.steven...@gmail.com wrote:
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.
Hi,

Take a look at ITemplate
Jun 27 '08 #3
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?
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: | last post by:
I'm wondering if it's possible, outside of the declaration of an ASP.NET 2.0 GridView, to programmatically style individual columns. For example, I might want to make the text in a particular...
0
by: Jaime Stuardo | last post by:
Hi all... I have the following curious problem, I have a GridView that I bind after I press a button in the web form. That grid has a template column, which contains a checkbox (in the header...
2
by: Wayne Deleer | last post by:
Hi All, I'm currently working on a project, and I've come to a part where I want to add data to a GridView. BUT, I want to do it programmatically, with alot of control over everything. In my...
0
by: GMartin | last post by:
I have a pop-up form with a three columned Grid that has checkboxes in a Template Column in the first/left-most column. (The form is to allow users to select "Members" of a group, where they check...
5
by: NKaufman | last post by:
<asp:GridView ID="Basic" runat="server" DataKeyNames="QuestionID,isHeading" AutoGenerateColumns="false" AllowPaging="true" PageSize="100"> <Columns> <asp:BoundField Visible="false"...
0
by: =?Utf-8?B?SlA=?= | last post by:
I have several data sources that use the same gridView. I need to remove columns from the gridview at run time where the DataBind.Eval statements dont apply to the query currently using the grid. ...
3
by: =?Utf-8?B?Um9iZXJ0IFNtaXRo?= | last post by:
Hi, I have a GridView with a checkbox column in it called FromInsight, however this is not bound to the dataset, its value is based on another column from the dataset called sourceid For each...
3
by: santoshjsh | last post by:
hello everyone, i have a gridview in which i have multiple checkboxes in a single column. means for every row in the gridview i have four checkboxes in one column e.g Add, Delete, Print,...
2
by: John Straumann | last post by:
Hello all: I am trying to populate a GridView with data being read from a call to a web service. I have seen plenty of examples that simply execute a SQL data reader, set the Grid data source to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.