Follow by Email

Friday, 10 August 2012

Step 1: Write this Past below javascript in the aspx source 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>

Step 2: Now data list as

<asp:DataList ID="dlExample" runat="server" RepeatDirection="Vertical" RepeatColumns="4" OnItemDataBound="dlExample_ItemDataBound" >
<ItemTemplate>
<table> <tr> <td> <asp:RadioButton ID="rdb" runat="server" /> </td> </tr> </table>
</ItemTemplate>
</asp:DataList>

Step 3: In code behind

protected void dlExample_ItemDataBound(object sender, DataListItemEventArgs e)
{
RadioButton rdb;
rdb = (RadioButton)e.Item.FindControl("rdb");
if(rdb != null)
rdb.Attributes.Add("onclick", "CheckOnes(this);");
}

0 comments:

Post a Comment


                                                            

 
Design by Abhinav Ranjan Sinha