473,473 Members | 1,947 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

VB.NET 2005 DataGridView Checkbox - Check Event need to know check status

6 New Member
VB.NET 2005 DataGridView Checkbox - Check Event need to know check status

I would like to use the DataGridView Checkbox like a normal checkbox.

When someone clicks on it I would expect that I could get a checked or changed event and be able to test if the box was checked or unchecked.

For a normal checkbox. When it is checked you can test chk.checked and it is the current visible stated. Someone checks it and your test for chk.checked is true. If it was unchecked then chk.checked is false.

In the DGV this does not seem to be the case.
You check the checkbox and there is some data in the other cells in that row and the value is nothing.
Private Sub grdLogon_CellContentClick
If grdLogon.Item(2, e.RowIndex).Value Is Nothing Then
'>>> It comes here
End If

If grdLogon.Item(2, e.RowIndex).Value Then
' Expeced checked but comes here when it was all the time
end if

The test grdLogon.Item(2, e.RowIndex).Value seems to work fine when used in other places (not a event from grdLogon.

I do not understand when this object has a value and when it is nothing nor how to make it work like a normal CheckBox.

Thanks & Happy Holidays!
Jack
Dec 21 '07 #1
1 12639
thenmozhivasanraj
11 New Member
For this first we have to get the row of the grid in object

like this

for (int i = 0; i <= bl_ctrlgridviewresult.Rows.Count-1; i++)
{
GridViewRow bl_gridviewrow;
bl_gridviewrow = bl_ctrlgridviewresult.Rows[i];
CheckBox cb = (CheckBox)bl_gridviewrow.FindControl("chkDelete");
if (cb.Checked)
{

DataRow dra = ds1.Rows[i - bl_incnt];
dra.Delete();
ds1.AcceptChanges();
bl_incnt = bl_incnt + 1;
}

}

chkDelete is the check box name which we are mentioned in itemtemplate.

try the above code.
Dec 24 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Just D | last post by:
Hi All, Does anybody know how to write the following code? I have a database table with a few columns including: ID , "Task" , ForceRun . I need to show the DataGrid on the ASPX page with...
4
by: Hexman | last post by:
Hello All, I'd like to find out the best way to add a cb column to a dgv and process efficiently. I see at least two ways of doing it. ------------------------------- 1) Add a cb to the dgv,...
8
by: Sid | last post by:
I hope someone could help me with this. I am trying to setup a criteria to decide when to allow/not allow user to click on the check box. logically it looks simple but I am not able to...
0
by: sydneycan | last post by:
Hi everyone. First time I'm posting something, so far I've been able to google it out but this time no luck so far... I have a html input checkbox on my page From the javascript 'switchlayers' in...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.