Re: Determine Which Checkboxes are Checked

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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>





.



Relevant Pages

  • Re: Updating Multiple Rolls Using PHP
    ... I am retrieving records from a table and I ... checkboxes, but my update loop is not working. ... array $_POST. ... Warning: Invalid argument supplied for foreach() in X: ...
    (comp.lang.php)
  • Re: Any Help? Stuck trying to create cgi perl program
    ... fills out textboxes and checkboxes while the program places the values ... from the text and checkboxes into a .csv file. ... foreach my $p ) { ...
    (comp.lang.perl.misc)
  • Re: Any Help? Stuck trying to create cgi perl program
    ... fills out textboxes and checkboxes while the program places the values ... from the text and checkboxes into a .csv file. ... foreach my $p ) { ...
    (comp.lang.perl.misc)
  • Re: Not sure if im doing this right
    ... I have a form that contains checkboxes. ... foreach ... CheckBox chk = ctl as CheckBox; ...
    (microsoft.public.dotnet.languages.csharp)
  • Determine Which Checkboxes are Checked
    ... I have an aspx page which contains a datalist, which in turn, is populated ... with checkboxes based on the contents of a SQL table. ... I know I've seen some nice tight routines to do ...
    (microsoft.public.dotnet.framework.aspnet)