Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1018161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:49:03+00:00 2026-05-16T10:49:03+00:00

Using This code: I am tring to fill the page with the data and

  • 0

Using This code: I am tring to fill the page with the data and I would like to edit the data when it is displayed, but it says could not find table ‘0’.

Dataset returns null value.

Could any one help me pls.

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                FillLists();
                int i = Convert.ToInt32(Request.QueryString["QID"]);
                // Response.Write(i);
                eTutorService ServiceProvider = new eTutorService();
                DataSet ds = new DataSet();
                ds = ServiceProvider.GetQuestionView(i);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    txtQuestion.Text = ds.Tables[0].Rows[0]["Question"].ToString();
                    txtOption1.Text = ds.Tables[0].Rows[0]["Option1"].ToString();
                    txtOption2.Text = ds.Tables[0].Rows[0]["Option2"].ToString();
                    txtOption3.Text = ds.Tables[0].Rows[0]["Option3"].ToString();
                    txtOption4.Text = ds.Tables[0].Rows[0]["Option4"].ToString();
                    txtCorrectAnswer.Text = ds.Tables[0].Rows[0]["CorrectAnswer"].ToString();
                    //Response.Write("ds.Tables[0].Rows[0][QuizId].ToString()" + ds.Tables[0].Rows[0]["QuizId"].ToString() +"</br>");
                    //Response.Write("ds.Tables[0].Rows[0][DifficultyLevel].ToString()" + ds.Tables[0].Rows[0]["DifficultyLevel"].ToString() + "</br>");
                    //Response.Write("ds.Tables[0].Rows[0][QuestionOrder].ToString()" + ds.Tables[0].Rows[0]["QuestionOrder"].ToString() + "</br>");
                    ddlPaper.Items.FindByValue(ds.Tables[0].Rows[0]["QuizId"].ToString()).Selected = true;
                    ddlDifficultyLevel.Items.FindByValue(ds.Tables[0].Rows[0]["DifficultyLevel"].ToString()).Selected = true;
                    ddlQuestionOrder.Items.FindByValue(ds.Tables[0].Rows[0]["QuestionOrder"].ToString()).Selected = true;
                }
            }
        }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        int QuestionId =0;
        if (Request.QueryString["QID"] != null)
        {
            QuestionId= Convert.ToInt32(Request.QueryString["QID"]);
        }
        string Question=txtQuestion.Text  ; 
        int DifficultyLevel=Convert.ToInt32 (ddlDifficultyLevel.SelectedItem.Value);
        int QuestionOrder = Convert.ToInt32(ddlQuestionOrder.SelectedItem.Value);
        int QuizId = Convert.ToInt32(ddlPaper.SelectedItem.Value);
        string CorrectAnswer=txtCorrectAnswer.Text;
        string Option1=txtOption1.Text;
        string Option2 = txtOption2.Text;
        string  Option3=txtOption3.Text ;
        string Option4=txtOption4.Text;
        eTutorService ServiceProvider = new eTutorService();
        DataSet ds = new DataSet();
        ds=ServiceProvider.EditQuestion(QuestionId, Question, DifficultyLevel, QuestionOrder,
            QuizId, CorrectAnswer, Option1, Option2, Option3, Option4);
        if (ds.Tables[0].Rows[0][0] != null)
        {
            pnlMain.Visible = false;
            pnlConfirm.Visible = true;
        }


    }

    protected void FillLists()
    {
        eTutorService ServiceProvider = new eTutorService();
        DataTable dtDiffLevelsdtDiffLevels = ServiceProvider.GetDiffLevels().Tables[0];
        DataTable dtQuizPapers = ServiceProvider.GetQuizPapers().Tables[0];

        ddlPaper.DataSource = dtQuizPapers;
        ddlPaper.DataValueField = dtQuizPapers.Columns["QuizID"].ToString();
        ddlPaper.DataTextField = dtQuizPapers.Columns["Subject"].ToString();
        ddlPaper.DataBind();

        ddlDifficultyLevel.DataSource = dtDiffLevelsdtDiffLevels;
        ddlDifficultyLevel.DataValueField = dtDiffLevelsdtDiffLevels.Columns["LEVEL_ID"].ToString();
        ddlDifficultyLevel.DataTextField = dtDiffLevelsdtDiffLevels.Columns["LEVEL_NAME"].ToString();
        ddlDifficultyLevel.DataBind();
    }

    protected void btnOk_Click(object sender, EventArgs e)
    {
        Response.Redirect("QuestionList.aspx", false);
    }

    protected void btnCancel_Click(object sender, EventArgs e)
    {
        if (Request.QueryString["QID"] != null)
        {
            Response.Redirect("QuestionView.aspx?QID=" + Request.QueryString["QID"].ToString(), false);
        }
    }

}:

Stack trace:

Cannot find table 0.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IndexOutOfRangeException: Cannot find table 0.

Source Error:

Line 60:             ds=ServiceProvider.EditQuestion(QuestionId, Question, DifficultyLevel, QuestionOrder,
Line 61:                 QuizId, CorrectAnswer, Option1, Option2, Option3, Option4);
Line 62:             if (ds.Tables[0].Rows[0][0] != null)
Line 63:             {
Line 64:                 pnlMain.Visible = false;


Source File: C:\Users\Star\Desktop\ETutor-Aug11\ETutor-Aug11\ETutor\EtutorServiceWebApp\QuestionEdit.aspx.cs    Line: 62

Stack Trace:

[IndexOutOfRangeException: Cannot find table 0.]
   System.Data.DataTableCollection.get_Item(Int32 index) +92
   EtutorServiceWebApp.QuestionEdit.btnSave_Click(Object sender, EventArgs e) in C:\Users\Star\Desktop\ETutor-Aug11\ETutor-Aug11\ETutor\EtutorServiceWebApp\QuestionEdit.aspx.cs:62
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T10:49:04+00:00Added an answer on May 16, 2026 at 10:49 am

    As the exception happens when you try to save, it looks like this line

    ServiceProvider.EditQuestion(...
    

    isn’t returning any tables in it’s DataSet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to save multiple image using this code. But instead its saving
I'm trying to play video from youtube using this code but I get this
I would like to make a layout like the one displayed on the this
Im tring to send a simple email with this code using google app engine.
I am using this code for on android just trying to convert string to
I am trying to assign objects in an NSMutableArray using this code - (IBAction)variablePressed:(UIButton
I'm trying to link to an external stylesheet using this code: <?php include(/homepages/9/myusername/htdocs/Mobile_Detect.php); $detect
I'm trying to implement Orbit Slider in my homepage using this code: <script type=text/javascript
I'm trying to update/change contact ringtone using this code: ContentValues values = new ContentValues();
I'm trying to set an image as the background using this code: root.setStyle(-fx-background-image: url('splash.jpg');

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.