Hello,

I am having difficulties trying to use a checkbox in a datagrid.  the checkbox is not 
binded to any table column. Obviously i am populating the datagrid with some records, 
but the first column (the checkbox) is not part of the dataset.   I just want the user 
to check on the checkbox if the record needs to be deleted.  My problem is that even 
if the box is checked, when I try to capture the value with the 
"btnDeleteSelectedClicked" event is always "false".  Also as soon as I click on the 
"Delete" link button in the datagrid footer, all the checkboxes in the grid return to 
"false".  What am I doing wrong... please help

TIA,
Victor
                                        
'*** This is my html ****
<asp:datagrid id="dgrTimeOffList" runat="server" 
                  OnSelectedIndexChanged="SelectionIndexChanged" 
                  OnPageIndexChanged="PageIndexChanged" 
                  AllowPaging="True" ForeColor="#004477" 
                  Font-Size="X-Small" Font-Names="Verdana,Arial,Helvetica,sans-serif" 
                  BorderWidth="1px" BorderColor="Black" BorderStyle="Solid" 
                  GridLines="None" CellSpacing="2" CellPadding="2" 
                  ShowFooter="True" Width="600px" Height="150px" PageSize="10">
        <SelectedItemStyle BorderStyle="Solid" BorderColor="#E0E0E0" 
BackColor="Silver">        </SelectedItemStyle>
        <AlternatingItemStyle BackColor="PaleGoldenrod">
        </AlternatingItemStyle>
        <HeaderStyle Height="20px" BackColor="#999999">
        </HeaderStyle>
        <Columns>
                <asp:TemplateColumn HeaderText=Select>
                        <ItemTemplate>
                                <center>
                                        <asp:CheckBox ID=DeleteThis Runat=server>
                                        </asp:CheckBox>
                                </center>
                        </ItemTemplate>
                        <FooterTemplate>                                               
                                                                                 
<asp:LinkButton ID=btnDeleteSelected OnClick="btnDeleteSelectedClicked" Runat=server>
                                        Delete
                                </asp:LinkButton>
                        </FooterTemplate>
                </asp:TemplateColumn>
        </Columns>
        <PagerStyle PageButtonCount="3" Mode="NumericPages">
        </PagerStyle>
</asp:datagrid>

'**** This is my code ****

Public Sub btnDeleteSelectedClicked(ByVal sender As Object, ByVal e As 
System.EventArgs)
        Dim intCount As Integer
        Dim _item As DataGridItem
        Dim cbxDelete As CheckBox

        For intCount = 0 To dgrTimeOffList.Items.Count - 1
            _item = dgrTimeOffList.Items(intCount)
            cbxDelete = _item.FindControl("DeleteThis")
            If cbxDelete.Checked Then
                Response.Write(cbxDelete.Checked.ToString)
            End If
        Next

End Sub

---
You are currently subscribed to dotnet as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search
Subscription Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/


Reply via email to