473,320 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Ctype error in Load control

Hi,

I am trying to load control as a record is being updated in a backend
database. The codes reads like this:

Dim ds As DataSet
CType(Page.FindControl("ddlStatus"),
DropDownList).SelectedValue = _status
Dim sql As String = "select * from _loanApp where status=" &
_status
ds =
SqlHelper.ExecuteDataset(ConfigurationSettings.App Settings("DSN"), _
CommandType.Text, sql)

CType(Page.FindControl("dgList"), DataGrid).DataSource = ds
CType(Page.FindControl("dgList"), DataGrid).DataBind()

but it is giving me this error.

System.NullReferenceException: Object reference not set to an instance
of an object.

The stack trace reads:

[NullReferenceException: Object reference not set to an instance of an
object.]

Any help is appreciated.

Feb 1 '07 #1
4 1106
What line gives the error? It will be one of the Page.FindControl commands
not finding the control you're asking for.

"AlecL" <sa********@hotmail.comwrote in message
news:11*********************@h3g2000cwc.googlegrou ps.com...
Hi,

I am trying to load control as a record is being updated in a backend
database. The codes reads like this:

Dim ds As DataSet
CType(Page.FindControl("ddlStatus"),
DropDownList).SelectedValue = _status
Dim sql As String = "select * from _loanApp where status=" &
_status
ds =
SqlHelper.ExecuteDataset(ConfigurationSettings.App Settings("DSN"), _
CommandType.Text, sql)

CType(Page.FindControl("dgList"), DataGrid).DataSource = ds
CType(Page.FindControl("dgList"), DataGrid).DataBind()

but it is giving me this error.

System.NullReferenceException: Object reference not set to an instance
of an object.

The stack trace reads:

[NullReferenceException: Object reference not set to an instance of an
object.]

Any help is appreciated.

Feb 1 '07 #2
On Feb 1, 10:51 am, "Aidy" <a...@noemail.xxxa.comwrote:
What line gives the error? It will be one of the Page.FindControl commands
not finding the control you're asking for.

"AlecL" <salmaan...@hotmail.comwrote in message

news:11*********************@h3g2000cwc.googlegrou ps.com...
Hi,
I am trying to load control as a record is being updated in a backend
database. The codes reads like this:
Dim ds As DataSet
CType(Page.FindControl("ddlStatus"),
DropDownList).SelectedValue = _status
Dim sql As String = "select * from _loanApp where status=" &
_status
ds =
SqlHelper.ExecuteDataset(ConfigurationSettings.App Settings("DSN"), _
CommandType.Text, sql)
CType(Page.FindControl("dgList"), DataGrid).DataSource = ds
CType(Page.FindControl("dgList"), DataGrid).DataBind()
but it is giving me this error.
System.NullReferenceException: Object reference not set to an instance
of an object.
The stack trace reads:
[NullReferenceException: Object reference not set to an instance of an
object.]
Any help is appreciated.- Hide quoted text -

- Show quoted text -
Yes it is the CType(Page.FindControl("ddlStatus"),
DropDownList).SelectedValue = _status line .

Thanks

Feb 1 '07 #3
Debug it. Set a breakpoint and see what returns null.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"AlecL" <sa********@hotmail.comwrote in message
news:11*********************@h3g2000cwc.googlegrou ps.com...
Hi,

I am trying to load control as a record is being updated in a backend
database. The codes reads like this:

Dim ds As DataSet
CType(Page.FindControl("ddlStatus"),
DropDownList).SelectedValue = _status
Dim sql As String = "select * from _loanApp where status=" &
_status
ds =
SqlHelper.ExecuteDataset(ConfigurationSettings.App Settings("DSN"), _
CommandType.Text, sql)

CType(Page.FindControl("dgList"), DataGrid).DataSource = ds
CType(Page.FindControl("dgList"), DataGrid).DataBind()

but it is giving me this error.

System.NullReferenceException: Object reference not set to an instance
of an object.

The stack trace reads:

[NullReferenceException: Object reference not set to an instance of an
object.]

Any help is appreciated.

Feb 1 '07 #4
ddlStatus won't be a dropdownlist with view state enabled then.

Can;t really say much more given the relevant code.

"AlecL" <sa********@hotmail.comwrote in message
news:11**********************@s48g2000cws.googlegr oups.com...
On Feb 1, 10:51 am, "Aidy" <a...@noemail.xxxa.comwrote:
>What line gives the error? It will be one of the Page.FindControl
commands
not finding the control you're asking for.

"AlecL" <salmaan...@hotmail.comwrote in message

news:11*********************@h3g2000cwc.googlegro ups.com...
Hi,
I am trying to load control as a record is being updated in a backend
database. The codes reads like this:
Dim ds As DataSet
CType(Page.FindControl("ddlStatus"),
DropDownList).SelectedValue = _status
Dim sql As String = "select * from _loanApp where status=" &
_status
ds =
SqlHelper.ExecuteDataset(ConfigurationSettings.App Settings("DSN"), _
CommandType.Text, sql)
CType(Page.FindControl("dgList"), DataGrid).DataSource = ds
CType(Page.FindControl("dgList"), DataGrid).DataBind()
but it is giving me this error.
System.NullReferenceException: Object reference not set to an instance
of an object.
The stack trace reads:
[NullReferenceException: Object reference not set to an instance of an
object.]
Any help is appreciated.- Hide quoted text -

- Show quoted text -

Yes it is the CType(Page.FindControl("ddlStatus"),
DropDownList).SelectedValue = _status line .

Thanks

Feb 1 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Douglas Buchanan | last post by:
I am using the following code instead of a very lengthly select case statement. (I have a lot of lookup tables in a settings form that are selected from a ListBox. The data adapters are given a...
3
by: Eamonn O'Connell | last post by:
Hi, We have an ASP.net application, where we dynamically add controls, in the Page_Load. Occasionally, when the user posts back the page (e.g. clicks Save button on the page), we get a "Failed...
1
by: Michael | last post by:
Hi, Any one know the problem of the following error: Thanks, m Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to...
5
by: Patrick | last post by:
I understand it is built in behaviour that if an ASP.NET's web.config is set to: <customErrors mode="RemoteOnly" /> then I only get a detailed error message on screen when the ASP.NET...
0
by: MarkD | last post by:
I have an ASP.NET (VB.NET) application that calls all VB6 COM DLL via Interop. The DLL uses functionality contained in a Custom OCX Control (Also VB6) that in turn contains a standard TreeView...
13
by: Carl Howarth | last post by:
Hello there, I am currently in the process of 'getting strict' with some of our aspx.vb files. I have a function that is called either when a datarepeater is bound or when a button on the...
0
by: HKSHK | last post by:
This list compares the error codes used in VB.NET 2003 with those used in VB6. Error Codes: ============ 3: This Error number is obsolete and no longer used. (Formerly: Return without GoSub)...
1
by: Justin Dutoit | last post by:
Hey. I'm trying to dynamically add User Controls to my page. It appears to work sometimes, but more often I get the error: Unable to cast object of type 'ASP.SearchControl' to type...
0
by: davidr | last post by:
Hi, I have a panel that I load user Control in no problem. The problem arrises when I do a post back on one of these user controls. I have button it does a click event. In this click event I...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.