Server Error in '/' Application.

Index and length must refer to a location within the string.
Parameter name: length

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.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length

Source Error:


Line 34:         {
Line 35:             dt.Rows[i]["Picture"] = dt.Rows[i]["Picture"].ToString().Replace("~/", "");
Line 36:             dt.Rows[i]["Detail"] = dt.Rows[i]["Detail"].ToString().Substring(0, 270);
Line 37:         }
Line 38:         rptrNew.DataSource = ds;

Source File: c:\inetpub\vhosts\lahorirentacar.com.pk\httpdocs\allnews.aspx.cs    Line: 36

Stack Trace:


[ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length]
   System.String.Substring(Int32 startIndex, Int32 length) +14342724
   allnews.GetMobilesPageWise(Int32 pageIndex) in c:\inetpub\vhosts\lahorirentacar.com.pk\httpdocs\allnews.aspx.cs:36
   allnews.Page_Load(Object sender, EventArgs e) in c:\inetpub\vhosts\lahorirentacar.com.pk\httpdocs\allnews.aspx.cs:22
   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.4110.0