I am having an issues connection from a Gridiview. I ahve a Gridview that load on Page Load event with a column that contains some True/False values.
I have a check box that I hope to allow the user to click to hide all of the False by passing a value to the Stored Procedure that loads the page an including the value of false in a SP query.
Problem is that when I click the check box to fire the event, I am getting a connection string problem.
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 65: End If
Line 66:
Line 67: itemDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("ConnectionStringmyConn").ToString() Line 68:
Line 69: 'SqlDataSource1UpdateTest.InsertCommandType = SqlDataSourceCommandType.StoredProcedure
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
portal_bulkStringUpdate.CheckBox1_CheckedChanged(Object sender, EventArgs e) in C:\Users\mhornung\Documents\Visual Studio 2008\WebSites\WebSite2\portal\bulkStringUpdate.aspx.vb:71
System.Web.UI.WebControls.CheckBox.OnCheckedChanged(EventArgs e) +111
System.Web.UI.WebControls.CheckBox.RaisePostDataChangedEvent() +134
System.Web.UI.WebControls.CheckBox.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent() +10
System.Web.UI.Page.RaiseChangedEvents() +165
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1485
Web config has string set up for all other pages and is working fine...
Set a break point in the check-changed method (I think, judging from your stack trace) and see what method you need to call to set the object value. The missing method is probably in the page or form load routine.
march11
Contributor
3110 Points
1394 Posts
Problem with Object Reference
Aug 03, 2011 12:46 PM|LINK
I am having an issues connection from a Gridiview. I ahve a Gridview that load on Page Load event with a column that contains some True/False values.
I have a check box that I hope to allow the user to click to hide all of the False by passing a value to the Stored Procedure that loads the page an including the value of false in a SP query.
Problem is that when I click the check box to fire the event, I am getting a connection string problem.
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 65: End If Line 66: Line 67: itemDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("ConnectionStringmyConn").ToString() Line 68: Line 69: 'SqlDataSource1UpdateTest.InsertCommandType = SqlDataSourceCommandType.StoredProcedureStack Trace:
Web config has string set up for all other pages and is working fine...
I bind to the Gridview later in the code.
itemDataSource.SelectCommand = SqlDataSourceCommandType.StoredProcedure itemDataSource.SelectCommand = "usp_getForTableData" ' Call stored procedure itemDataSource.SelectParameters.Add("currTable", Session("currUserTable")).ToString() itemDataSource.SelectParameters.Add("needsTrans", sortTF) ' Dim rowsAffected As Integer = 0 GridView1.DataSource = itemDataSource GridView1.DataBind()qwe123kids
All-Star
48619 Points
7957 Posts
MVP
Re: Problem with Object Reference
Aug 03, 2011 12:58 PM|LINK
Hi,
Seems Your not getting any Information in
in follwing line
ConfigurationManager.ConnectionStrings("ConnectionStringmyConn").ToString()
Avinash Tiwari
Remember to click “Mark as Answer” on the post, if it helps you.
march11
Contributor
3110 Points
1394 Posts
Re: Problem with Object Reference
Aug 03, 2011 01:04 PM|LINK
That would be true. Any ideas on the cause of the matter?
qwe123kids
All-Star
48619 Points
7957 Posts
MVP
Re: Problem with Object Reference
Aug 03, 2011 02:15 PM|LINK
http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.connectionstrings.aspx#Y342
check your Web.config file..
is connection string "ConnectionStringmyConn" define
Avinash Tiwari
Remember to click “Mark as Answer” on the post, if it helps you.
march11
Contributor
3110 Points
1394 Posts
Re: Problem with Object Reference
Aug 03, 2011 02:31 PM|LINK
Yes and as I stated it is working on other web pages with no problem.
I have other pages that work with no problem.
monoliths
Member
169 Points
85 Posts
Re: Problem with Object Reference
Aug 03, 2011 02:40 PM|LINK
It looks like the connection string isn't getting instantiated on post-back. I have had similar issues in the past.
march11
Contributor
3110 Points
1394 Posts
Re: Problem with Object Reference
Aug 03, 2011 02:44 PM|LINK
How did you solve this?
monoliths
Member
169 Points
85 Posts
Re: Problem with Object Reference
Aug 03, 2011 03:09 PM|LINK
Set a break point in the check-changed method (I think, judging from your stack trace) and see what method you need to call to set the object value. The missing method is probably in the page or form load routine.