Click here to Skip to main content
15,035,600 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
if (!IsPostBack) {
			cmd.Connection = con;

			for (j = 0; j <= Session.Keys.Count - 1; j++) {


I got the error below Line;

Exception Details: System.IndexOutOfRangeException: There is no row at position 1.

Source Error:

Line 39: Label l = default(Label);
Line 40: l = (Label)v.FindControl("Label1");
Line 41: l.Text = dt.Rows[ctr]["Serial"] + ".";
Line 42: l = (Label)v.FindControl("Label2");
Line 43: dt.Rows[ctr]["question"]=l.Text ;

Source File: e:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\WebSites\Subbu\WebSite6\Default2.aspx.cs Line: 41

i got Error below line

l.Text = dt.Rows[ctr]["Serial"] + ".";
Updated 5-Nov-11 20:01pm

The array a[] should be as big as the Session.Keys, check that first.
Amir Mahfoozi 6-Nov-11 2:05am
+5 I Agree
Mehdi Gholam 6-Nov-11 2:10am
Resolution for First Error:

Have you defined a properly? I tried your code with below syntax and it runs without any Error.
    string[] a = new string[]{};

    for (int j = 0; j <= Session.Keys.Count - 1; j++)
        a[j] = Session.Keys[j];

catch (Exception ex)
    string error = ex.Message;

Resolution for Second Error:

Debug your code and check value of dt, it should not be null. Also check what value you are getting from dt.Rows[ctr]["Serial"].

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900