473,503 Members | 10,012 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.NET DataGrid Checkbox

Hi
I've got a grid with a check box in first column and Delete Button outside
of grid.
The following code is never returning a true in the delete button click that
the check box is checked! Why? What am I doing wrong? using VS2003

Thanks for any help!

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Aircraft.aspx.vb"
Inherits="AFARSAdmin2003.Aircraft"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Administrator - Aircraft Fleet</title>
<link rel="stylesheet" type="text/css" href="../../styles/adminStyle.css">
</HEAD>
<body>
<form id="Aircraft" method="post" runat="server">
..
..
<asp:DataGrid EnableViewState=True runat="server" ID="AircraftGrid"
CellPadding="0" AutoGenerateColumns="False">
HeaderStyle Font-Size="12pt" Font-Italic="True" Font-Bold="True"
HorizontalAlign="Center" ForeColor="MediumBlue"
VerticalAlign="Middle"></HeaderStyle>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox id="chkBox" runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="EffectiveDate" HeaderText="Effective Date"
DataFormatString="{0:d}">
<iItemStyle Width="83px"></ItemStyle>
</asp:BoundColumn>
..
..
..

Private Sub btnDelete_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnDelete.Click
' Walk the grid looking for selected rows
Dim i As Integer = 0
Dim cb As Boolean
Dim dgi As DataGridItem
For i = 0 To AircraftGrid.Items.Count - 1
dgi = AircraftGrid.Items(i)
cb = CType(dgi.Cells(0).FindControl("chkBox"), CheckBox).Checked
If cb Then
' NEVER GETS HERE !
End If
Next

Jul 21 '05 #1
0 1028

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

Similar topics

0
2143
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
1507
by: Jim Heavey | last post by:
Hello, I am starting to learn how to use the Datagrid and I have a couple of questions. My datagrid as a checkbox in it. It looks like the following in the datagrid... <asp:TemplateColumn...
2
3105
by: Sebi | last post by:
Hello all is it possible to add a checkbox in a DataGrid for Boolean Data? Thanks in advance
0
2387
by: mike | last post by:
Hi there: I've read an excellent "how to"-article by Microsoft (no. 306227) - partly cited cited at the end of this email). I have implemented the code related to the part "How to Add a...
4
1836
by: Mike | last post by:
Hi, Is there a possibility to have one of the Web Control Datagrid's column as a Calendar when editing data? Any resources on this subject? Thanks Mike
7
2255
by: Lars Netzel | last post by:
If I put a checkbox in a datagrid (ASP.NET) and set the Autopostback to true I can catch OnChange event on checkbox but how do I then catch what DataGridItemIndex is? Can I use some Event in the...
2
2444
by: Mortar | last post by:
i have a datagrid with 2 columns. the 1st column contains an id which will be used by the database for the selected checkbox records. the 2nd column is a template column containing a server...
1
4213
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get...
3
3131
by: Fao, Sean | last post by:
I have a DataGrid that I'm adding CheckBox controls to at runtime (in the code behind) and I'm not sure if I'm doing it correctly. First of all, I noticed that the MyDataGrid.Columns.Add() method...
7
2491
by: rn5a | last post by:
The first column of a DataGrid has a CheckBox for all the rows. I want that when users check a CheckBox, the BackColor of that entire row in the DataGrid should change to a different color. To...
0
7267
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,...
1
6976
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...
0
7449
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...
1
4993
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4666
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
3160
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
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1495
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 ...
1
729
muto222
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.