471,356 Members | 1,511 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

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 991

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Jim Heavey | last post: by
2 posts views Thread by Sebi | last post: by
reply views Thread by mike | last post: by
4 posts views Thread by Mike | last post: by
7 posts views Thread by Lars Netzel | last post: by
2 posts views Thread by Mortar | last post: by
3 posts views Thread by Fao, Sean | last post: by
7 posts views Thread by rn5a | last post: by

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.