Server Error in '/' Application.

Object reference not set to an instance of an object.

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.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 52:         SqlCommand cmd = new SqlCommand("Select pagename from datapagename where pageid = @pageid;", cn);
Line 53:         cmd.Parameters.Add("@pageid", int.Parse(Request.QueryString["datapage_id"].ToString()));
Line 54:         lbltitle.Text = cmd.ExecuteScalar().ToString();
Line 55:         cmd.Dispose();
Line 56: 

Source File: d:\HostingSpaces\eltekindia.com\eltekindia.com\wwwroot\data.aspx.cs    Line: 54

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
   data.gettitle() in d:\HostingSpaces\eltekindia.com\eltekindia.com\wwwroot\data.aspx.cs:54
   data.Page_Load(Object sender, EventArgs e) in d:\HostingSpaces\eltekindia.com\eltekindia.com\wwwroot\data.aspx.cs:30
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
   System.Web.UI.Control.OnLoad(EventArgs e) +95
   System.Web.UI.Control.LoadRecursive() +59
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678


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