Welcome to Dream.In.Code
Become an Expert!

Join 150,390 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,087 people online right now. Registration is fast and FREE... Join Now!




Preventing radiobutton multicheck in datalist

 
Reply to this topicStart new topic

Preventing radiobutton multicheck in datalist

anki1234
6 Mar, 2008 - 05:04 AM
Post #1

New D.I.C Head
*

Joined: 6 Mar, 2008
Posts: 1

I am developing online exam application but the problem is that when the user login and come across the questions we have 4 options for each question with corresponding radiobuttons but user can check more than one option which i don't want
In short i want to prevent user from choosing more than one options
Any help would be greatly appreciated
I am a newbee to .net

CODE

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>AnkurDeepakShop</title>
</head>
<body>
<form method="post" runat="server">
    <asp:DataList ID="DataList1" runat="server" DataKeyField="QID" DataSourceID="SqlDataSource1"
        Width="400" BackColor="MistyRose">
        
        <ItemTemplate>
        
            <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Question") %>'>
            </asp:Label>
            </b>
            <br />
    
            <asp:RadioButton ID="rd1"  runat="server" Text='<%# Eval("Option1") %>'/>
            <br />
            <asp:RadioButton ID="RadioButton1" runat="server"  Text='<%# Eval("Option2 ") %>'/>
            <br />
            <asp:RadioButton ID="RadioButton2" runat="server"  Text='<%# Eval("Option3") %>'/>
          <br />
            <asp:RadioButton ID="RadioButton3" runat="server" Text='<%# Eval("Option4") %>'/>
            
            </b>
        </ItemTemplate>
    </asp:DataList>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        SelectCommand="select * from quiz "></asp:SqlDataSource>
        </form>
</body>
</html>



Thanks in advance
User is offlineProfile CardPM
+Quote Post

girasquid
RE: Preventing Radiobutton Multicheck In Datalist
6 Mar, 2008 - 07:51 AM
Post #2

Barbarbar
Group Icon

Joined: 3 Oct, 2006
Posts: 1,299



Thanked: 19 times
Dream Kudos: 725
My Contributions
Use the GroupName attribute to group radiobuttons together - just set the GroupName for the 4 to "foo".
User is online!Profile CardPM
+Quote Post

Footsie
RE: Preventing Radiobutton Multicheck In Datalist
6 Mar, 2008 - 12:07 PM
Post #3

D.I.C Regular
Group Icon

Joined: 20 Sep, 2007
Posts: 308



Thanked: 4 times
Dream Kudos: 50
My Contributions
Use the RadioButtonList which provides exactly that functionality. (only allows one click)
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 05:28PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month