John,

Thanks for the response.  Yeah, I am aware of the delete, edit columns in datagrid. 
The problem is that they work only on individual rows.  In the applicatoin I am 
developing the users need to delete more than 10 records at a time... so it would be a 
pain for them.  But, I actually found what the problem was. I was binding the datagrid 
on the load event of the page, but I forgot to put the code in the "not ispostback" if 
statement... so it was regenerating the grid every time the page refreshed... and 
since the checkbox is not binded to anything, it returned its value to "false".... it 
has been a long day, and that was a stupid ovelook on my part.. once again, thanks for 
the input.

Victor

-----Original Message-----
From: Black, John S. [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 26, 2002 4:51 PM
To: dotnet
Subject: RE: Datagrid Footer link button problem



Victor,
  Have not worked with checkboxes in Datagrids before so not sure of
what the error may be but I will look into it.  In the meantime, you may
already know this but there is a "delete button" column type for
datagrids that will allow you to execute a procedure (ie run a delete
query) for individual rows.  If you click on the "property builder" link
for your datagrid and then open the + next to the button column (under
columns section of the control window) you can then add a 'delete'
column to your datagrid (in place of your checkbox column).  You then
assign the name of your delete procedure to the "OnDeleteCommand"
parameter of your datagrid and set the "DataKeyField" property of the
datagrid to the id column of your data (whatever identifies each row)
and reference it in the delete procedure (
myDataGrid.DataKeys(objArgs.Item.ItemIndex) ) where objArgs is of type
"DataGridCommandEventArgs".  Therefore, a user simply clicks 'delete'
for a given row and the row is removed from the datagrid/database.  The
operation is very fast and is easy to implement.  Will look into the
checkbox issue......

John

-----Original Message-----
From: Victor Dios [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, November 26, 2002 2:12 PM
To: dotnet
Subject: Datagrid Footer link button problem


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.unsub%%

---------
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/



The content contained in this electronic message is not intended to
constitute formation of a contract binding TWTC.  TWTC will be
contractually bound only upon execution, by an authorized officer, of
a contract including agreed terms and conditions or by express
application of its tariffs.

This message is intended only for the use of the individual or entity
to which it is addressed. If the reader of this message is not the
intended recipient, or the employee or agent responsible for
delivering the message to the intended recipient, you are hereby
notified that any dissemination, distribution or copying of this
message is strictly prohibited. If you have received this
communication in error, please notify us immediately by replying to
the sender of this E-Mail or by telephone.

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

---------
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/



---
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