datagrid question

chand

Freshman
Joined
Feb 4, 2004
Messages
30
hi
i am displaying checkbox,id and name in datagrid.when user selects 2 or more checkboxes and clicks confirm button on the webpage i need those id's of checked rows.how do i get them.

i would appreciate any help

thaks
 
Try something similar to this:

Code:
Dim di As System.Web.UI.WebControls.DataGridItem
Dim cb As CheckBox

For Each di In DataGrid1.Items
    cb = DirectCast(di.FindControl("CheckBox1"), CheckBox)

    If cb.Checked Then
        Response.Write(di.Cells(1).Text() & "<br>")
    End If
Next
Note: I am assuming that the second column is ID and it is a BoundColumn. Also that the code will only work if the checkbox is a Web Control and not a Html Control (ie. '<asp:CheckBox...' instead of '<input type="checkbox"...'). Hope this helps.
 
Back
Top