About Dropdownlist ..urgent.

G

Guest

Hi,
I'm encounted problem deal with dropdownlist databinding..
below is my code:
Dim ddlPerName As DropDownList
ddlPerName = CType(e.Item.FindControl("A"), DropDownList)

Dim ddpN As ArrayList = BindPersonName()
ddlPerName.DataSource = ddpN
ddlPerName.DataBind()

Error message as below:

Server Error in '/TestWeb1' 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 143: 'ASSIGN THE ARRAY LIST TO THE DROPROWNLIST.
Line 144: 'ddlPerName.DataSource = ddpN
Line 145: ddlPerName.DataBind()
Line 146: dd.DataSource = ddpN
Line 147: dd.DataBind()


Source File: c:\inetpub\wwwroot\TestWeb1\WebForm7(RImage).aspx.vb Line:
145

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an
object.]
TestWeb1.WebForm7.DataGrid2_EditCommand(Object source,
DataGridCommandEventArgs e) in
c:\inetpub\wwwroot\TestWeb1\WebForm7(RImage).aspx.vb:145
System.Web.UI.WebControls.DataGrid.OnEditCommand(DataGridCommandEventArgs
e)
System.Web.UI.WebControls.DataGrid.OnBubbleEvent(Object source, EventArgs
e)
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
System.Web.UI.WebControls.DataGridItem.OnBubbleEvent(Object source,
EventArgs e)
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e)

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain() +1292

why ?? any ideas..

thanks in advance.

daniel.
 
S

Sergey Poberezoskiy

Daniel,

Take a look at the result of your
e.Item.FindControl("A")
to see whether it actually finds the control you after -
this may solve your problem.

HTH
-----Original Message-----
Hi,
I'm encounted problem deal with dropdownlist databinding..
below is my code:
Dim ddlPerName As DropDownList
ddlPerName = CType(e.Item.FindControl("A"), DropDownList)

Dim ddpN As ArrayList = BindPersonName()
ddlPerName.DataSource = ddpN
ddlPerName.DataBind()

Error message as below:

Server Error in '/TestWeb1' 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 143: 'ASSIGN THE ARRAY LIST TO THE DROPROWNLIST.
Line 144: 'ddlPerName.DataSource = ddpN
Line 145: ddlPerName.DataBind()
Line 146: dd.DataSource = ddpN
Line 147: dd.DataBind()


Source File: c:\inetpub\wwwroot\TestWeb1\WebForm7 (RImage).aspx.vb Line:
145

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an
object.]
TestWeb1.WebForm7.DataGrid2_EditCommand(Object source,
DataGridCommandEventArgs e) in
c:\inetpub\wwwroot\TestWeb1\WebForm7(RImage).aspx.vb:145
System.Web.UI.WebControls.DataGrid.OnEditCommand (DataGridCommandEventArgs
e)
System.Web.UI.WebControls.DataGrid.OnBubbleEvent (Object source, EventArgs
e)
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
System.Web.UI.WebControls.DataGridItem.OnBubbleEvent (Object source,
EventArgs e)
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
System.Web.UI.WebControls.Button.OnCommand (CommandEventArgs e)

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEv
entHandler.RaisePostBackEvent(String eventArgument)
 

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