DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: datalist radiobutton

  1. #1
    Join Date
    Feb 2006
    Posts
    8

    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

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    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!

  3. #3
    Join Date
    Feb 2006
    Posts
    8
    thanks! ill give that a bash

  4. #4
    Join Date
    Jul 2007
    Posts
    1

    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>


    <aspataList 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" />
    </aspataList>

    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....



    Quote 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

  1. how to Edit Child datalist in a parent Datalist
    By naijacoder in forum ASP.NET
    Replies: 0
    Last Post: 04-26-2006, 11:12 PM
  2. DataList Access + Dynamic Template
    By Psion in forum ASP.NET
    Replies: 2
    Last Post: 12-05-2005, 05:56 PM
  3. datalist layout
    By silverfox_1188 in forum ASP.NET
    Replies: 0
    Last Post: 05-11-2005, 08:34 PM
  4. DataList not using <BODY> tag settings
    By jrothlander in forum ASP.NET
    Replies: 6
    Last Post: 04-27-2005, 04:43 PM
  5. DataList validation before updating record
    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center