Click to See Complete Forum and Search --> : Datagrid


NewOne1
July 11th, 2003, 03:09 AM
Hi,

I have datagrid, and add collumn with checkbox:


<asp:TemplateColumn ItemStyle-Width="15px">
<ItemTemplate>
<input type="checkbox" id="checkbox" name="checkbox" runat="server" VALUE="checkbox" />
</ItemTemplate>
</asp:TemplateColumn>


How can I check which checkbox was cheked (can be more than one)? And how can I access information in that datagrig?

coolbiz
July 14th, 2003, 12:02 PM
Loop through the DataGrid ITEMS (this is a collection of DataGridItem objects) and for each item, use the FindControl() method to get your check box control. You can manipulate it from there.

-Cool Bizs

Rohit Kukreti
July 18th, 2003, 07:08 AM
Hi,
Try this code
foreach( DataGridItem di in DataGrid1.Items )
{
HtmlInputCheckBox cb = (HtmlInputCheckBox)(di.FindControl("checkbox")) ;
if( cb!=null && cb.Checked )
{
//Do the required processing
}
}

hope this helps

--
Rohit

ammar_ar
August 5th, 2003, 12:20 AM
hi,

try these lines of code

dim DataItem as datagrid item
dim x as system.web.ui.webcontrol.checkbox

for each dataitem in YourDataGridName.Items

x = dataitem.findcontrol("yourcheckboxname")

if x.check = true then
' the check box in that row was checked