Ctype error in Load control

  • Thread starter Thread starter AlecL
  • Start date Start date
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.
 
What line gives the error? It will be one of the Page.FindControl commands
not finding the control you're asking for.
 
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
 
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
 
Back
Top