Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Request you to please help me with the below issue.. Website (alnadwacentre.com) is not loading... when I checked with godaddy techsupport, they told that it's a code issue and reach out to developer... our developer is not with our centre anymore ... hence thought of getting help here.

Below is the output from the website:

Server Error in '/' Application.
There is no row at position 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: There is no row at position 0.

Source Error:


Line 46:         DataSet ds = new DataSet();
Line 47:         ds = ObjAdd.DisplayPrayerTime();
Line 48:         lblPrayerTime.Text = ds.Tables[0].Rows[0][0].ToString();
Line 49:     }
Line 50:    

Source File: g:\pleskvhosts\alnadwacentre.com\httpdocs\Index.aspx.cs    Line: 48

Stack Trace:


[IndexOutOfRangeException: There is no row at position 0.]
   System.Data.RBTree`1.GetNodeByIndex(Int32 userIndex) +2519522
   System.Data.DataRowCollection.get_Item(Int32 index) +20
   Home.DisplayPrayerTimeTable() in g:\pleskvhosts\alnadwacentre.com\httpdocs\Index.aspx.cs:48
   Home.Page_Load(Object sender, EventArgs e) in g:\pleskvhosts\alnadwacentre.com\httpdocs\Index.aspx.cs:19
   System.Web.UI.Control.OnLoad(EventArgs e) +108
   System.Web.UI.Control.LoadRecursive() +90
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1533

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4654.0


--------------------------
Our index.aspx.cs file:

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration;

public partial class Home : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            DisplayLink();
            DisplayNews();
            DisplayPrayerTimeTable();
        }
    }
    public void DisplayLink()
    {
        string link = string.Empty;
        ImperoIT.ManagePrayerTime ObjAdd = new ImperoIT.ManagePrayerTime();
        DataSet ds = new DataSet();
        ds = ObjAdd.DisplayLink();
        GV_Link.DataSource = ds;
        GV_Link.DataBind();
    }
    public void DisplayNews()
    {
        string News = string.Empty;
        ImperoIT.ManagePrayerTime ObjAdd = new ImperoIT.ManagePrayerTime();
        DataSet ds = new DataSet();
        ds = ObjAdd.DisplayNewsTitel();
        NewsRepeater.DataSource = ds;
        NewsRepeater.DataBind();
        ObjAdd = null;
        ds.Dispose();
    }
    public void DisplayPrayerTimeTable()
    {
        string News = string.Empty;
        ImperoIT.ManagePrayerTime ObjAdd = new ImperoIT.ManagePrayerTime();
        DataSet ds = new DataSet();
        ds = ObjAdd.DisplayPrayerTime();
        lblPrayerTime.Text = ds.Tables[0].Rows[0][0].ToString();
    }   
}


What I have tried:

I don't have developer skills, hence cannot check much... your help is very much appreciated.
Posted
Updated 25-Oct-23 10:39am
v2

Your code is assuming this line:
C#
ds = ObjAdd.DisplayPrayerTime();

is returning a bunch of rows. It does not check to see if any tables or rows have been returned by DisplayPrayerTime.

Why is it not returning rows? Nobody can tell you because you didn't show that the code for DisplayPrayerTime, nor any queries it's executing against a database, assuming there is one.
 
Share this answer
 
Comments
Mohammed Aarif Shaikh 17-Oct-23 9:19am    
Thanks for you reply...

Please guide what I have to action here... as am not from developer background...

DO you want me to change/update anything in index.aspx.cs file ? please let me know what to update.

index.aspx.cs file content copied above in main question.
Dave Kreskowiak 17-Oct-23 9:35am    
Read my post again: "Nobody can tell you because you didn't show that the code for DisplayPrayerTime, nor any queries it's executing against a database, assuming there is one."
Mohammed Aarif Shaikh 17-Oct-23 11:01am    
isnt this is code -

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration;

public partial class Home : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
DisplayLink();
DisplayNews();
DisplayPrayerTimeTable();
}
}
public void DisplayLink()
{
string link = string.Empty;
ImperoIT.ManagePrayerTime ObjAdd = new ImperoIT.ManagePrayerTime();
DataSet ds = new DataSet();
ds = ObjAdd.DisplayLink();
GV_Link.DataSource = ds;
GV_Link.DataBind();
}
public void DisplayNews()
{
string News = string.Empty;
ImperoIT.ManagePrayerTime ObjAdd = new ImperoIT.ManagePrayerTime();
DataSet ds = new DataSet();
ds = ObjAdd.DisplayNewsTitel();
NewsRepeater.DataSource = ds;
NewsRepeater.DataBind();
ObjAdd = null;
ds.Dispose();
}
public void DisplayPrayerTimeTable()
{
string News = string.Empty;
ImperoIT.ManagePrayerTime ObjAdd = new ImperoIT.ManagePrayerTime();
DataSet ds = new DataSet();
ds = ObjAdd.DisplayPrayerTime();
lblPrayerTime.Text = ds.Tables[0].Rows[0][0].ToString();
}

}
Dave Kreskowiak 17-Oct-23 12:35pm    
Sigh. Reporting the exact same code you originally posted doesn't change anything.

What you DID NOT post is the code for whatever "DisplayPrayerTime()" is. That's where the problem is going to be.
your code wants to check if there is something in the table before you try to pass it to a value because if it is empty it will give you an index out of bounds error eg. if table size >= 0 ds = table[0] rows[0][0] else break/continue code
 
Share this answer
 
Comments
Richard Deeming 20-Nov-23 4:20am    
As already explained in solution 1 last month.

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