473,395 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

generating radio buttons dynamically on columns table Online question paper generator

20
I want to create an online objective type question paper generator which generates random questions based on the number of questions to be generated from a particular subject say science.

I have a stored procedure that generates the questions randomly and inserting them into a temp table for displaying them in a GridView.

Further to this I would like to retrieve the question followed by a radio button against each option stored in four columns so that user can select one option among these.

How do I do this?

I would like to use the option select to further evaluate the answer.

Hope I have made myself clear.
Any guidance will be of great help.

Thanks

(eg)
1. One byte equals to ---Col1 in table
optA 2 bits----Col2 in table
optB 4 bits----Col3
optC 8 bits----Col4
OptD 16 bits--Col5
Answer 16 bits--Col6



my stored procedure in sql server 2000 is as below

Expand|Select|Wrap|Line Numbers
  1. ALTER PROCEDURE [dbo].[quesRand] (@NO_ques int)
  2.     -- Add the parameters for the stored procedure here
  3. AS
  4. BEGIN
  5. set NOCOUNT ON    
  6. DECLARE @intFlag INT
  7. DECLARE @random INT
  8. DECLARE @upper INT
  9. DECLARE @lower INT
  10.  
  11. SET @intFlag = 1
  12.  
  13.  
  14. set @lower=1
  15. set @upper=100
  16. create table #test4 (cd_no int,cd_name nvarchar(50),date_received smalldatetime,
  17. shipped_with_remarks nvarchar(50))
  18. WHILE (@intFlag <=@NO_ques)
  19.  
  20.  
  21. BEGIN
  22. select @random=Round(((@upper-@lower-1))*RAND()+@lower,0)
  23.  
  24.  
  25. PRINT @random
  26. insert into #test4
  27. select * from science where cd_no=@random
  28.  
  29. SET @intFlag = @intFlag + 1
  30.  
  31. END
  32.  select * from #test4
  33.  
  34. END 

I am using Visual studio 2005 and .aspx page is as below


Expand|Select|Wrap|Line Numbers
  1. %@ Page Language="C#" AutoEventWireup="true" debug="true"  CodeFile="Ques.aspx.cs" Inherits="_Default" %>
  2.  
  3. <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
  4.  
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7. <head runat="server">
  8.     <title>Software CD search</title>
  9.     <script type="text/javascript"  src="jquery-1.4.2.min.js"></script>
  10. <script type="text/javascript">
  11. $(function () {
  12. $('#txtNo_ques').keydown(function (e) {
  13. if (e.shiftKey || e.ctrlKey || e.altKey) {
  14. e.preventDefault();
  15. } else {
  16. var key = e.keyCode;
  17. if (!((key == 8) || (key == 46) || (key >= 35 && key <= 40) || (key >= 48 && key <= 57) || (key >= 96 && key <= 105))) {
  18. e.preventDefault();
  19. }
  20. }
  21. });
  22. });
  23. </script>
  24.  
  25. </head>
  26. <body >
  27.     <form id="form1" action="Ques.aspx.cs" runat="server">
  28.  
  29.  
  30.  
  31.     <div align=center>
  32.         <asp:Label ID="lblNo_ques" runat="server" Text="Enter the no. of questions"></asp:Label>
  33.         <asp:TextBox ID="txtNo_ques" runat="server"></asp:TextBox>
  34.         <asp:RequiredFieldValidator ID="Validate_No_ques" runat="server" ControlToValidate="txtNo_ques"
  35.             ErrorMessage="Please Enter the no. of questions!"></asp:RequiredFieldValidator>
  36.     </div>
  37.  
  38.  
  39.     <div align="center" style="margin:20px;" >
  40.         <asp:Button ID="genQues" runat="server" Text="Generate & View" OnClick="genQues_Click" />
  41.     </div>
  42.  
  43.  
  44.     <div>
  45.         &nbsp;</div>
  46.     <hr />
  47.     <div align="center" >
  48.         <asp:GridView ID="dgv1" runat="server" BackColor="LightSteelBlue" BorderColor="Crimson" BorderStyle="Double" BorderWidth="2px" ForeColor="Black" AutoGenerateDeleteButton="True" AutoGenerateEditButton="True" AutoGenerateSelectButton="True">
  49.             <EditRowStyle BackColor="Teal" BorderColor="#C00000" BorderWidth="3px" />
  50.             <AlternatingRowStyle BackColor="InactiveCaption" BorderColor="Green" />
  51.             <RowStyle BackColor="#FFE0C0" BorderColor="#004040" BorderStyle="Ridge" BorderWidth="3px" />
  52.             <HeaderStyle BackColor="Thistle" BorderColor="PaleGreen" BorderStyle="Dashed" />
  53.         </asp:GridView>
  54.  
  55.     </div>
  56.  
  57.  
  58.  
  59.     </form>
  60. </body>
  61. </html>
  62.  
  63.  
  64.  

My code behind file Ques.aspx.cs is as follows

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Web;
  5. using System.Web.Security;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. using System.Web.UI.WebControls.WebParts;
  9. using System.Web.UI.HtmlControls;
  10. using System.Data.SqlClient;
  11. using System.Collections.Generic;
  12.  
  13. public partial class _Default : System.Web.UI.Page 
  14. {
  15.  
  16.  
  17.     protected void Page_Load(object sender, EventArgs e)
  18.     {
  19.  
  20.     }
  21.  
  22.         protected void genQues_Click(object sender, EventArgs e)
  23.     {
  24.         string constring = ConfigurationManager.AppSettings.Get("con").ToString();
  25.         SqlConnection conn = new SqlConnection(constring);
  26.         conn.Open();
  27.  
  28.         SqlCommand check = new SqlCommand("quesRand", conn);
  29.         check.CommandType = CommandType.StoredProcedure;
  30.  
  31.         check.Parameters.Add(new SqlParameter("@NO_ques", SqlDbType.Int));
  32.         check.Parameters["@NO_ques"].Value = txtNo_ques.Text;
  33.  
  34.  
  35.  
  36.         SqlDataAdapter da = new SqlDataAdapter(check);
  37.         DataSet ds = new DataSet();
  38.         da.Fill(ds);
  39.         this.dgv1.DataSource = ds.Tables[0].DefaultView;
  40.  
  41.         dgv1.DataBind();
  42.  
  43.         conn.Close();
  44.  
  45.     }
  46.  
May 31 '13 #1
0 1574

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Suzanne | last post by:
Hi, I have a form which our clients can fill in with their personal details. As part of the information we store there is a section - areas of interest - this is a number of radio buttons. ...
3
by: Jay | last post by:
I noticed somewhere on the net that a post mentioned that there was a bug in the datagrid, radio buttons and a repeater. Something about the radio buttons are not mutually exclusive. (will this be...
2
by: Rob | last post by:
Hi all, I've got multiple sets of radio button that are dynamically created in code and populated by a database query. The query returns about 20 recordsets with 3 radio buttons per recordset and...
2
by: James P. | last post by:
Help, I need to display radio buttons on a form. The data is from SQL table: each row in each table is displayed as a radio button. I have multiple SQL tables so I understand I need to put...
1
by: Jerry | last post by:
We have a 10-question quiz for kids, each question being a yes or no answer using radio selections. I'd like to keep a current total of yes's and no's at the bottom of the quiz (if the user selects...
0
by: david | last post by:
Yesterday I got a suggestion about the web page layout from Stas. Thanks, Stas. However, I have a problem to drag the existing radio buttons into the table cell. Case: I have a lot of radion...
7
by: Milo333 | last post by:
Hi Please help, how do i write an if statement to check through 4 radio buttons, if none of the 4 buttons are selected than a message box must popup saying incomplete form, please complete the...
0
by: LavanyaM | last post by:
Hi, In our app we need to create dynamic radio buttons. There should be three radio buttons and this set is dynamic accroding to the data this is my code: <th width="5%"...
7
by: moksha | last post by:
Hi, I am new to javascript and i am facing a problem in coding. plz help me out. I am using javascript for dynamically creating a table row which contains text boxes and radio...
11
by: Twayne | last post by:
Hi, Newbie to PHP here, no C or other relevant background, so pretty niave w/r to the nuances etc. but I think this is pretty basic. XP Pro, SP2+, PHP 4.4.7, XAMPP Local Apache Server...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.