-
datalist radiobutton
ive been hunting all over the net for this solution but found nothing.
ASP.NET 1.1
I want to know if it is possible to use a radiobutton in a datalist which will ONLY select 1 radiobutton?
if so - how? it seems I can select as many radiobuttons as I like in 1 "column" but i dont want this.
please help
-
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
thanks! ill give that a bash
-
Solution
Hi Please find the solution.... so you want to select one radio button which are in datalist.
Javascript:
ASPX PAGE CODE:::::::::::::::::::::::::::::::
<script type="text/javascript" language="javascript">
function CheckOnes(spanChk){
var oItem = spanChk.children;
var theBox= (spanChk.type=="radio") ?
spanChk : spanChk.children.item[0];
xState=theBox.unchecked;
elm=theBox.form.elements;
for(i=0;i<elm.length;i++)
if(elm[i].type=="radio" &&
elm[i].id!=theBox.id)
{
elm[i].checked=xState;
}
}
</script>
<asp ataList Width="100%" ID="dataListName" DataKeyField="SOME_ID" runat="server"
RepeatLayout="Table" RepeatDirection="Vertical" RepeatColumns="4" ShowFooter="False" ShowHeader="False" BorderColor="#99CCCC" GridLines="Vertical" OnItemDataBound="SOMENAMEItemBound" >
<ItemTemplate>
<table width="100%">
<tr>
<td>
<asp:RadioButton ID="rdb" runat="server" />
</td>
</tr>
</table>
</ItemTemplate>
<ItemStyle BorderWidth="1px" />
</asp ataList>
CODE BEHIND CODE:::::::::::::::::::::
protected void SOMENAMEItemBound(object sender, DataListItemEventArgs e)
{
RadioButton rdb;
rdb = (RadioButton)e.Item.FindControl("rdb");
if(rdb != null)
rdb.Attributes.Add("onclick", "CheckOnes(this);");
}
Please do it like this I am sure it will solve your problem....
 Originally Posted by firehawk
ive been hunting all over the net for this solution but found nothing.
ASP.NET 1.1
I want to know if it is possible to use a radiobutton in a datalist which will ONLY select 1 radiobutton?
if so - how? it seems I can select as many radiobuttons as I like in 1 "column" but i dont want this.
please help
Similar Threads
-
By naijacoder in forum ASP.NET
Replies: 0
Last Post: 04-26-2006, 11:12 PM
-
By Psion in forum ASP.NET
Replies: 2
Last Post: 12-05-2005, 05:56 PM
-
By silverfox_1188 in forum ASP.NET
Replies: 0
Last Post: 05-11-2005, 08:34 PM
-
By jrothlander in forum ASP.NET
Replies: 6
Last Post: 04-27-2005, 04:43 PM
-
By Carlos Gonzalez in forum ASP.NET
Replies: 0
Last Post: 02-15-2001, 04:54 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|