Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > BOOK: Beginning ASP.NET 2.0 and Databases
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 2.0 and Databases
This is the forum to discuss the Wrox book Beginning ASP.NET 2.0 and Databases by John Kauffman, Bradley Millington; ISBN: 9780471781349
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 2.0 and Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 27th, 2009, 02:19 PM
Registered User
Join Date: Oct 2009
Location: Ahmedabad, India
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ritesh7 Send a message via Yahoo to ritesh7
Red face Moving to Next Record Help Required


I am developing a website which has feature for online exam. I have 4 radio buttons for 4 options, 1 label for question and next and previous button. When the page is loaded it display the question and 4 answers. When I click on next or previous buttons. How to move to next or previous record in database with datareader or datatable till the last record. I am pasting the code below. It is in ASP.net with C# and SQL Server 2005 Please help me
public partial class Exam : System.Web.UI.Page
    SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\RiTech.mdf;Integrated Security=True;User Instance=True");

    public DataTable getData()
        SqlCommand cmd = new SqlCommand("Select * from Exam",con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataTable dt = new DataTable();
        return dt;
    protected void Page_Load(object sender, EventArgs e)
        DataTable dt = getData();
        lblQuestion.Text = dt.Rows[0]["Question"].ToString();
        int count = 0;
        Session ["dt"]=dt;
        Session["count"] = count;
    protected void btnNext_Click(object sender, EventArgs e)
        if (Session["dt"] != null)
            DataTable dt = (DataTable)Session["dt"];
            int count = (int)Session["count"];
            count = count + 1;
            lblQuestion.Text = dt.Rows[count]["Question"].ToString();  


Last edited by ritesh7; December 27th, 2009 at 02:25 PM.. Reason: code

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Find Last Record and Add new keyed record causualuser Access VBA 3 February 9th, 2009 08:24 AM
clicking through from record to record on form mat41 Access 3 January 9th, 2009 08:26 AM
how to add new record as first record in dataset hunzian78@yahoo.com ASP.NET 1.0 and 1.1 Professional 4 April 21st, 2006 05:23 AM
Record locking - user needs the next queued record cbtoolkit SQL Server 2000 0 December 6th, 2004 08:29 AM
Sub record not associating with Main record Ron V Access 1 August 31st, 2004 09:21 AM

All times are GMT -4. The time now is 11:47 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.