Re: Determine Which Checkboxes are Checked
- From: "Wayne Wengert" <wayneSKIPSPAM@xxxxxxxxxxx>
- Date: Sun, 5 Feb 2006 07:25:16 -0700
Kostas;
Exactly what I wanted. Thank you
"Konstantinos Pantos" <KonstantinosPantos@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote
in message news:D515D565-B346-45B3-BF66-C6F37B50B6EF@xxxxxxxxxxxxxxxx
A quick way to establish which DataList items are selected is by iterating
the DataList's Items Collection:
foreach (DataListItem item in DataList1.Items)
{
if (((CheckBox)item.FindControl("CheckBox1")) != null &&
((CheckBox)item.FindControl("CheckBox1")).Checked)
{
//Do what you want with this row
}
}
Hope this helps...
--
_________________________
Kostas Pantos [MCP]
http://kostas.pantos.name
"Wayne Wengert" wrote:
I have an aspx page which contains a datalist, which in turn, is
populated
with checkboxes based on the contents of a SQL table (see code below). I
want a routine to go through all the checkboxes in this set and determine
which ones the user checked. I know I've seen some nice tight routines to
do
this but I had no luck Googling for it.
================== Code ======================
<asp:DataList ID="DataList1" runat="server" DataKeyField="Interest"
RepeatColumns="4" DataSourceID="SqlDataSource1"
CellSpacing="2" SelectedIndex="0" Font-Bold="False" Font-Italic="False"
Font-Overline="False" Font-Strikeout="False" Font-Underline="False"
HorizontalAlign="Left" RepeatDirection="Horizontal" ShowFooter="False"
ShowHeader="False" Height="248px" Width="448px">
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Text='<%# Eval("Interest")
%>'
/>
</ItemTemplate>
</asp:DataList>
.
- References:
- Determine Which Checkboxes are Checked
- From: Wayne Wengert
- Determine Which Checkboxes are Checked
- Prev by Date: Re: Use IHttpHandler not ASPX for pro web apps
- Next by Date: Re: ContentPlaceHolder tag in ASP.NET 2.0 prevents design view in FrontPage 2003
- Previous by thread: Determine Which Checkboxes are Checked
- Next by thread: I have changed extension aspx ...
- Index(es):
Relevant Pages
|