Ctype error in Load control

A

AlecL

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.AppSettings("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.
 
A

Aidy

What line gives the error? It will be one of the Page.FindControl commands
not finding the control you're asking for.
 
A

AlecL

What line gives the error? It will be one of the Page.FindControl commands
not finding the control you're asking for.




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.AppSettings("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
 
A

Aidy

ddlStatus won't be a dropdownlist with view state enabled then.

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

AlecL said:
What line gives the error? It will be one of the Page.FindControl
commands
not finding the control you're asking for.




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.AppSettings("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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top