I have take radiobuttonlist and i have checked one radio the associated Radiobuttons will checked that buttons will inside datalist to radiobuttonlist this process using javascript function plz give me answer
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>RadioButtonList using Selection</title>
<script language="javascript" type="text/javascript">
function GetRDBValue() {
var radio = document.getElementsByName('rblSelection');
for (var i = 0; i < radio.length; i++) {
if (radio[i].checked) {
alert(radio[i].value);
if (radio[i].value == "1") {
var datalist = document.getElementById('<%=dlRadiobtnlist.ClientID%>').childNodes[0];
alert(datalist);
var rbl = datalist.getElementsByTagName("rblSelection1");
alert(rbl);
for (var i = 0; i < rbl.length; i++) {
if (rbl[i].type == "1") {
rbl[i].type.checked = true;
}
}
}
if (radio[i].value == "0") {
var datalist = document.getElementById('<%=dlRadiobtnlist.ClientID%>').childNodes[0];
alert(datalist);
var rbl = datalist.getElementsByTagName("rblSelection1");
for (var i = 0; i < rbl.length; i++) {
if (rbl[i].type == "0") {
rbl[i].type.checked = true;
}
}
}
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>
<asp:Label ID="lblRblist" runat="server" Text="Radiobutton Selection" ForeColor="Black"></asp:Label>
</td>
<td>
<asp:RadioButtonList ID="rblSelection" runat="server" RepeatDirection="Horizontal"
AutoPostBack="true" ValidationGroup="g1">
<asp:ListItem Value="1">Yes</asp:ListItem>
<asp:ListItem Value="0">No</asp:ListItem>
</asp:RadioButtonList>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidat" runat="server" ControlToValidate="rblSelection"
ErrorMessage="Please Select one" ForeColor="Red">
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:DataList ID="dlRadiobtnlist" runat="server" RepeatColumns="3" RepeatDirection="Vertical"
GridLines="Both">
<ItemTemplate>
<asp:RadioButtonList ID="c" runat="server" RepeatDirection="Vertical" GridLines="Both"
AutoPostBack="true" ValidationGroup="g1">
<asp:ListItem Value="1">Yes</asp:ListItem>
<asp:ListItem Value="0">No</asp:ListItem>
</asp:RadioButtonList>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
This is my code not working please help me