mcselasvegas
asked on
checkboxes in datalist
Hi experts,
i am writing an email notification control. The User should be able to choose from several check boxes. (send email : immediatly, daily or never)
This is displayed in a datalist since there several subjects that the user can choose from... each itemtemplate has the 3 checkboxes
I want to be able to have the user select (immediatly and daily) if he checks (never) the other two checkboxes should get automatically unchecked (java)... and viceversa
Thanks for your help
i am writing an email notification control. The User should be able to choose from several check boxes. (send email : immediatly, daily or never)
This is displayed in a datalist since there several subjects that the user can choose from... each itemtemplate has the 3 checkboxes
I want to be able to have the user select (immediatly and daily) if he checks (never) the other two checkboxes should get automatically unchecked (java)... and viceversa
Thanks for your help
<asp:DataList id="dlstManufacturers" HorizontalAlign="Center" runat="server" BorderWidth="0" CellPadding="0" ShowFooter="True" ShowHeader="True" DataKeyField="RecordId" GridLines="None" BorderStyle="Solid" Width="100%">
<HeaderTemplate>
<table width="100%" cellpadding="5" cellspacing="0" border="0">
<tr>
<td>
<asp:Label CssClass="NormalBold" ID="Label1" runat="server" Text="Manufacturer"></asp:Label>
</td>
<td>
<asp:Label CssClass="NormalBold" ID="Label2" runat="server" Text="Send Immediately"></asp:Label>
</td>
<td>
<asp:Label CssClass="NormalBold" ID="Label3" runat="server" Text="Send Twice Daily"></asp:Label>
</td>
<td>
<asp:Label CssClass="NormalBold" ID="Label4" runat="server" Text="Never Send"></asp:Label>
</td>
</tr>
</HeaderTemplate>
<ITEMTEMPLATE>
<tr>
<td>
<asp:Label id="lblManufacturerId" Text='<%# DataBinder.Eval(Container.DataItem, "RecordId")%>' Runat="server" Visible="false"></asp:Label>
<asp:Label CssClass="Normal" id="lblManufacturerName" Text='<%# DataBinder.Eval(Container.DataItem, "ManufacturerName")%>' runat="server"></asp:Label>
</td>
<td>
<asp:CheckBox ID="chbImmediately" runat="server" />
</td>
<td>
<asp:CheckBox ID="chbDaily" runat="server" />
</td>
<td>
<asp:CheckBox ID="chbNever" runat="server" />
</td>
</tr>
</ITEMTEMPLATE>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:DataList>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Greg,
You hit the nail on the head... Thank you so much...
Oliver
You hit the nail on the head... Thank you so much...
Oliver
ASKER
Hi Greg,
May I ask you one more question...
what would I use If I wanted a button to select all send daily checkboxes at once?
and to continue that thought one button for select all immediatly and one for select all never checkboxes?
Thank you,
Oliver
May I ask you one more question...
what would I use If I wanted a button to select all send daily checkboxes at once?
and to continue that thought one button for select all immediatly and one for select all never checkboxes?
Thank you,
Oliver
I've attached a sample that should help to get you there...
Note: toggling checked = true / false is based on the current value of the top checkbox in the column.
Test.htm.txt
Note: toggling checked = true / false is based on the current value of the top checkbox in the column.
Test.htm.txt
ASKER
Hi greg,
this works great in plain html... but the datalist control add thes pesty <span> tags that srew up the java script...
here is the control code I use
<asp:DataList id="dlstManufacturers" HorizontalAlign="Center" runat="server" CellPadding="0" ShowFooter="True" ShowHeader="True" DataKeyField="RecordId" OnItemDataBound="ItemDataB ound" OnItemCommand="ItemCommand " RepeatLayout="Flow" RepeatDirection="Horizonta l">
<HeaderTemplate>
<table id="myTable" cellpadding="5" cellspacing="0" border="0">
<tr>
<td width="150">
<asp:Label CssClass="NormalBold" ID="Label1" runat="server" Text="Manufacturer"></asp: Label>
</td>
<td width="150">
<asp:Label CssClass="NormalBold" ID="Label2" runat="server" Text="Send Immediately"></asp:Label>
</td>
<td width="150">
<asp:Label CssClass="NormalBold" ID="Label3" runat="server" Text="Send Twice Daily"></asp:Label>
</td>
<td width="150">
<asp:Label CssClass="NormalBold" ID="Label4" runat="server" Text="Never Send"></asp:Label>
</td>
</tr>
</HeaderTemplate>
<ITEMTEMPLATE>
<tr>
<td width="150">
<asp:Label id="lblManufacturerId" Text='<%# DataBinder.Eval(Container. DataItem, "RecordId")%>' Runat="server" Visible="false"></asp:Labe l>
<asp:Label CssClass="Normal" id="lblManufacturerName" Text='<%# DataBinder.Eval(Container. DataItem, "ManufacturerName")%>' runat="server"></asp:Label >
</td>
<td width="150">
<asp:CheckBox ID="chbImmediately" runat="server" onclick="SingleSelect('chk ',this);" />
</td>
<td width="150">
<asp:CheckBox ID="chbDaily" runat="server" />
</td>
<td width="150">
<asp:CheckBox ID="chbNever" runat="server" />
</td>
</tr>
</ITEMTEMPLATE>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:DataList>
this creates this html code...
<span id="dnn_ctr783_EmailNotifi cationSett ings_dlstM anufacture rs"><span>
<table id="myTable" cellpadding="5" cellspacing="0" border="0">
<tr>
<td width="150">
<span id="dnn_ctr783_EmailNotifi cationSett ings_dlstM anufacture rs_ctl00_L abel1" class="NormalBold">Manufac turer</spa n>
</td>
<td width="150">
<span id="dnn_ctr783_EmailNotifi cationSett ings_dlstM anufacture rs_ctl00_L abel2" class="NormalBold">Send Immediately</span>
</td>
<td width="150">
<span id="dnn_ctr783_EmailNotifi cationSett ings_dlstM anufacture rs_ctl00_L abel3" class="NormalBold">Send Twice Daily</span>
</td>
<td width="150">
<span id="dnn_ctr783_EmailNotifi cationSett ings_dlstM anufacture rs_ctl00_L abel4" class="NormalBold">Never Send</span>
</td>
</tr>
</span><span>
<tr>
<td width="150">
<span id="dnn_ctr783_EmailNotifi cationSett ings_dlstM anufacture rs_ctl01_l blManufact urerName" class="Normal">Acura</span >
</td>
<td width="150">
<input id="dnn_ctr783_EmailNotifi cationSett ings_dlstM anufacture rs_ctl01_c hbImmediat ely" type="checkbox" name="dnn$ctr783$EmailNoti ficationSe ttings$dls tManufactu rers$ctl01 $chbImmedi ately" onclick="SingleSelect('chk ',this);" />
</td>
<td width="150">
<input id="dnn_ctr783_EmailNotifi cationSett ings_dlstM anufacture rs_ctl01_c hbDaily" type="checkbox" name="dnn$ctr783$EmailNoti ficationSe ttings$dls tManufactu rers$ctl01 $chbDaily" />
</td>
<td width="150">
<input id="dnn_ctr783_EmailNotifi cationSett ings_dlstM anufacture rs_ctl01_c hbNever" type="checkbox" name="dnn$ctr783$EmailNoti ficationSe ttings$dls tManufactu rers$ctl01 $chbNever" />
</td>
</tr>
</span><span>...
any ideas how I could work around that?
I really appreciate your help..
this works great in plain html... but the datalist control add thes pesty <span> tags that srew up the java script...
here is the control code I use
<asp:DataList id="dlstManufacturers" HorizontalAlign="Center" runat="server" CellPadding="0" ShowFooter="True" ShowHeader="True" DataKeyField="RecordId" OnItemDataBound="ItemDataB
<HeaderTemplate>
<table id="myTable" cellpadding="5" cellspacing="0" border="0">
<tr>
<td width="150">
<asp:Label CssClass="NormalBold" ID="Label1" runat="server" Text="Manufacturer"></asp:
</td>
<td width="150">
<asp:Label CssClass="NormalBold" ID="Label2" runat="server" Text="Send Immediately"></asp:Label>
</td>
<td width="150">
<asp:Label CssClass="NormalBold" ID="Label3" runat="server" Text="Send Twice Daily"></asp:Label>
</td>
<td width="150">
<asp:Label CssClass="NormalBold" ID="Label4" runat="server" Text="Never Send"></asp:Label>
</td>
</tr>
</HeaderTemplate>
<ITEMTEMPLATE>
<tr>
<td width="150">
<asp:Label id="lblManufacturerId" Text='<%# DataBinder.Eval(Container.
<asp:Label CssClass="Normal" id="lblManufacturerName" Text='<%# DataBinder.Eval(Container.
</td>
<td width="150">
<asp:CheckBox ID="chbImmediately" runat="server" onclick="SingleSelect('chk
</td>
<td width="150">
<asp:CheckBox ID="chbDaily" runat="server" />
</td>
<td width="150">
<asp:CheckBox ID="chbNever" runat="server" />
</td>
</tr>
</ITEMTEMPLATE>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:DataList>
this creates this html code...
<span id="dnn_ctr783_EmailNotifi
<table id="myTable" cellpadding="5" cellspacing="0" border="0">
<tr>
<td width="150">
<span id="dnn_ctr783_EmailNotifi
</td>
<td width="150">
<span id="dnn_ctr783_EmailNotifi
</td>
<td width="150">
<span id="dnn_ctr783_EmailNotifi
</td>
<td width="150">
<span id="dnn_ctr783_EmailNotifi
</td>
</tr>
</span><span>
<tr>
<td width="150">
<span id="dnn_ctr783_EmailNotifi
</td>
<td width="150">
<input id="dnn_ctr783_EmailNotifi
</td>
<td width="150">
<input id="dnn_ctr783_EmailNotifi
</td>
<td width="150">
<input id="dnn_ctr783_EmailNotifi
</td>
</tr>
</span><span>...
any ideas how I could work around that?
I really appreciate your help..
ASKER
Hi Greg,
Just disregard the last question... I switched to repeater and it works fine now...
Thanx fo all your help... ;o)
Just disregard the last question... I switched to repeater and it works fine now...
Thanx fo all your help... ;o)
Alternatively, you might consider switching to a RadioButtonList that has: Never, Immediately, Twice Daily, Both
A RadioButtonList would make the HTML work in more scenarios, and wouldn't require any JavaScript.
Open in new window