473,728 Members | 1,903 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Listbox & Object Not Referenced

yop
All

When I try to get the text from my listbox I am get an
error which is listed below.

Any ideas?

Thanks

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.NullRefe renceException: Object
reference not set to an instance of an object.

Source Error:
Line 83: 'Need to bind the textboxes from the
choice picked out from the list
Line 84: ' Dim ListItem As ListItem =
lstUsers.Select edItem
Line 85: UserName.Text = stUsers.Selecte dItem.Text
Line 86:
Line 87: 'Get the user details and fill textboxes

Source File: C:\Dev\Asset Register
SW\SourceCode\D otNet\ASP.NET\A SP.NET Asset
Register\AssetR egister\ViewUse rs.aspx.vb Line: 85

Stack Trace:
[NullReferenceEx ception: Object reference not set to an
instance of an object.]
AssetRegister.V iewUser.lstUser s_SelectedIndex Changed
(Object sender, EventArgs e) in C:\Dev\Asset Register
SW\SourceCode\D otNet\ASP.NET\A SP.NET Asset
Register\AssetR egister\ViewUse rs.aspx.vb:85

System.Web.UI.W ebControls.List Control.OnSelec tedIndexChang
ed(EventArgs e)

System.Web.UI.W ebControls.List Box.System.Web. UI.IPostBackD
ataHandler.Rais ePostDataChange dEvent()
System.Web.UI.P age.RaiseChange dEvents()
System.Web.UI.P age.ProcessRequ estMain()

Nov 17 '05 #1
10 2248
Unless an Item has been selected, this value will be null.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
The more I learn, the less I know.

"yop" <yo*@oceanfree. net> wrote in message
news:0a******** *************** *****@phx.gbl.. .
All

When I try to get the text from my listbox I am get an
error which is listed below.

Any ideas?

Thanks

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.NullRefe renceException: Object
reference not set to an instance of an object.

Source Error:
Line 83: 'Need to bind the textboxes from the
choice picked out from the list
Line 84: ' Dim ListItem As ListItem =
lstUsers.Select edItem
Line 85: UserName.Text = stUsers.Selecte dItem.Text
Line 86:
Line 87: 'Get the user details and fill textboxes

Source File: C:\Dev\Asset Register
SW\SourceCode\D otNet\ASP.NET\A SP.NET Asset
Register\AssetR egister\ViewUse rs.aspx.vb Line: 85

Stack Trace:
[NullReferenceEx ception: Object reference not set to an
instance of an object.]
AssetRegister.V iewUser.lstUser s_SelectedIndex Changed
(Object sender, EventArgs e) in C:\Dev\Asset Register
SW\SourceCode\D otNet\ASP.NET\A SP.NET Asset
Register\AssetR egister\ViewUse rs.aspx.vb:85

System.Web.UI.W ebControls.List Control.OnSelec tedIndexChang
ed(EventArgs e)

System.Web.UI.W ebControls.List Box.System.Web. UI.IPostBackD
ataHandler.Rais ePostDataChange dEvent()
System.Web.UI.P age.RaiseChange dEvents()
System.Web.UI.P age.ProcessRequ estMain()


Nov 17 '05 #2
yop
Kevin

I have an item selected alright, daft idea but could it
be something to do with postback or something?

I click on the item and call the following:

Private Sub lstUsers_Select edIndexChanged( ByVal sender As
Object, ByVal e As System.EventArg s) _
Handles lstUsers.Select edIndexChanged

'Need to bind the textboxes from the choice picked out
from the list
UserName.Text = lstUsers.Select edItem.Text
thanks
-----Original Message-----
Unless an Item has been selected, this value will be null.
--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
The more I learn, the less I know.

"yop" <yo*@oceanfree. net> wrote in message
news:0a******* *************** ******@phx.gbl. ..
All

When I try to get the text from my listbox I am get an
error which is listed below.

Any ideas?

Thanks

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.NullRefe renceException: Object reference not set to an instance of an object.

Source Error:
Line 83: 'Need to bind the textboxes from the
choice picked out from the list
Line 84: ' Dim ListItem As ListItem =
lstUsers.Select edItem
Line 85: UserName.Text = stUsers.Selecte dItem.Text Line 86:
Line 87: 'Get the user details and fill textboxes
Source File: C:\Dev\Asset Register
SW\SourceCode\D otNet\ASP.NET\A SP.NET Asset
Register\AssetR egister\ViewUse rs.aspx.vb Line: 85

Stack Trace:
[NullReferenceEx ception: Object reference not set to an
instance of an object.]
AssetRegister.V iewUser.lstUser s_SelectedIndex Changed
(Object sender, EventArgs e) in C:\Dev\Asset Register
SW\SourceCode\D otNet\ASP.NET\A SP.NET Asset
Register\AssetR egister\ViewUse rs.aspx.vb:85

System.Web.UI.W ebControls.List Control.OnSelec tedIndexChang ed(EventArgs e)

System.Web.UI.W ebControls.List Box.System.Web. UI.IPostBackD ataHandler.Rais ePostDataChange dEvent()
System.Web.UI.P age.RaiseChange dEvents()
System.Web.UI.P age.ProcessRequ estMain()


.

Nov 17 '05 #3
Try using .SelectedValue property.....

TextBox1.Text = ListBox1.Select edValue()

If it fails too, i would check whether it is selected the
first time user comes on the web page. If that is also
set, and it is not working, i will try to see
whether "value" property returns anything. If that fails,
i have no idea why its not working.....

Since it is going to "SelectedIndexC hanged" event i am
hoping that the "AutoPostBa ck" is set to true for your
control.

Thanks,

Tapasvi


-----Original Message-----
Kevin

I have an item selected alright, daft idea but could it
be something to do with postback or something?

I click on the item and call the following:

Private Sub lstUsers_Select edIndexChanged( ByVal sender As
Object, ByVal e As System.EventArg s) _
Handles lstUsers.Select edIndexChanged

'Need to bind the textboxes from the choice picked out
from the list
UserName.Tex t = lstUsers.Select edItem.Text
thanks
-----Original Message-----
Unless an Item has been selected, this value will be

null.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
The more I learn, the less I know.

"yop" <yo*@oceanfree. net> wrote in message
news:0a****** *************** *******@phx.gbl ...
All

When I try to get the text from my listbox I am get an
error which is listed below.

Any ideas?

Thanks

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.NullRefe renceException:Object reference not set to an instance of an object.

Source Error:
Line 83: 'Need to bind the textboxes from the
choice picked out from the list
Line 84: ' Dim ListItem As ListItem =
lstUsers.Select edItem
Line 85: UserName.Text =stUsers.Select edItem.Text Line 86:
Line 87: 'Get the user details and filltextboxes
Source File: C:\Dev\Asset Register
SW\SourceCode\D otNet\ASP.NET\A SP.NET Asset
Register\AssetR egister\ViewUse rs.aspx.vb Line: 85

Stack Trace:
[NullReferenceEx ception: Object reference not set to an
instance of an object.]
AssetRegister.V iewUser.lstUser s_SelectedIndex Changed
(Object sender, EventArgs e) in C:\Dev\Asset Register
SW\SourceCode\D otNet\ASP.NET\A SP.NET Asset
Register\AssetR egister\ViewUse rs.aspx.vb:85

System.Web.UI. WebControls.Lis tControl.OnSele ctedIndexChang ed(EventArgs e)

System.Web.UI. WebControls.Lis tBox.System.Web .UI.IPostBackD ataHandler.Rais ePostDataChange dEvent()
System.Web.UI.P age.RaiseChange dEvents()
System.Web.UI.P age.ProcessRequ estMain()


.

.

Nov 17 '05 #4
Is the ListBox's AutoPostBack property set to True?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
The more I learn, the less I know.

"yop" <yo*@oceanfree. net> wrote in message
news:04******** *************** *****@phx.gbl.. .
Kevin

I have an item selected alright, daft idea but could it
be something to do with postback or something?

I click on the item and call the following:

Private Sub lstUsers_Select edIndexChanged( ByVal sender As
Object, ByVal e As System.EventArg s) _
Handles lstUsers.Select edIndexChanged

'Need to bind the textboxes from the choice picked out
from the list
UserName.Text = lstUsers.Select edItem.Text
thanks
-----Original Message-----
Unless an Item has been selected, this value will be

null.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
The more I learn, the less I know.

"yop" <yo*@oceanfree. net> wrote in message
news:0a******* *************** ******@phx.gbl. ..
All

When I try to get the text from my listbox I am get an
error which is listed below.

Any ideas?

Thanks

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.NullRefe renceException: Object reference not set to an instance of an object.

Source Error:
Line 83: 'Need to bind the textboxes from the
choice picked out from the list
Line 84: ' Dim ListItem As ListItem =
lstUsers.Select edItem
Line 85: UserName.Text = stUsers.Selecte dItem.Text Line 86:
Line 87: 'Get the user details and fill textboxes
Source File: C:\Dev\Asset Register
SW\SourceCode\D otNet\ASP.NET\A SP.NET Asset
Register\AssetR egister\ViewUse rs.aspx.vb Line: 85

Stack Trace:
[NullReferenceEx ception: Object reference not set to an
instance of an object.]
AssetRegister.V iewUser.lstUser s_SelectedIndex Changed
(Object sender, EventArgs e) in C:\Dev\Asset Register
SW\SourceCode\D otNet\ASP.NET\A SP.NET Asset
Register\AssetR egister\ViewUse rs.aspx.vb:85

System.Web.UI.W ebControls.List Control.OnSelec tedIndexChang ed(EventArgs e)

System.Web.UI.W ebControls.List Box.System.Web. UI.IPostBackD ataHandler.Rais ePostDataChange dEvent()
System.Web.UI.P age.RaiseChange dEvents()
System.Web.UI.P age.ProcessRequ estMain()


.

Nov 17 '05 #5
Another possiblity: Is the ListBox dynamically added to the Page?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
The more I learn, the less I know.

"yop" <yo*@oceanfree. net> wrote in message
news:04******** *************** *****@phx.gbl.. .
Kevin

I have an item selected alright, daft idea but could it
be something to do with postback or something?

I click on the item and call the following:

Private Sub lstUsers_Select edIndexChanged( ByVal sender As
Object, ByVal e As System.EventArg s) _
Handles lstUsers.Select edIndexChanged

'Need to bind the textboxes from the choice picked out
from the list
UserName.Text = lstUsers.Select edItem.Text
thanks
-----Original Message-----
Unless an Item has been selected, this value will be

null.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
The more I learn, the less I know.

"yop" <yo*@oceanfree. net> wrote in message
news:0a******* *************** ******@phx.gbl. ..
All

When I try to get the text from my listbox I am get an
error which is listed below.

Any ideas?

Thanks

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.NullRefe renceException: Object reference not set to an instance of an object.

Source Error:
Line 83: 'Need to bind the textboxes from the
choice picked out from the list
Line 84: ' Dim ListItem As ListItem =
lstUsers.Select edItem
Line 85: UserName.Text = stUsers.Selecte dItem.Text Line 86:
Line 87: 'Get the user details and fill textboxes
Source File: C:\Dev\Asset Register
SW\SourceCode\D otNet\ASP.NET\A SP.NET Asset
Register\AssetR egister\ViewUse rs.aspx.vb Line: 85

Stack Trace:
[NullReferenceEx ception: Object reference not set to an
instance of an object.]
AssetRegister.V iewUser.lstUser s_SelectedIndex Changed
(Object sender, EventArgs e) in C:\Dev\Asset Register
SW\SourceCode\D otNet\ASP.NET\A SP.NET Asset
Register\AssetR egister\ViewUse rs.aspx.vb:85

System.Web.UI.W ebControls.List Control.OnSelec tedIndexChang ed(EventArgs e)

System.Web.UI.W ebControls.List Box.System.Web. UI.IPostBackD ataHandler.Rais ePostDataChange dEvent()
System.Web.UI.P age.RaiseChange dEvents()
System.Web.UI.P age.ProcessRequ estMain()


.

Nov 17 '05 #6
Yes it is a property. Here is the code that works fine on
my machine.....

Code behind >>>>>

Private Sub ListBox1_Select edIndexChanged( ByVal sender As
System.Object, ByVal e As System.EventArg s)
Handles ListBox1.Select edIndexChanged
TextBox1.Text = ListBox1.Select edValue()
End Sub

ASPX code >>>>>

<HTML>
<HEAD>
<title>WebForm1 </title>
<meta name="GENERATOR " content="Micros oft
Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" content="Visual
Basic .NET 7.1">
<meta name="vs_defaul tClientScript"
content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form id="Form1" method="post"
runat="server">
<asp:ListBox id="ListBox1"
style="Z-INDEX: 101; LEFT: 288px; POSITION: absolute; TOP:
168px"
runat="server"
Width="160px" Height="168px" AutoPostBack="T rue">
<asp:ListItem
Value="Tapasvi" >Tapasvi</asp:ListItem>
<asp:ListItem Value="Tap
at Work">Tap at Work</asp:ListItem>
</asp:ListBox>
<asp:TextBox id="TextBox1"
style="Z-INDEX: 102; LEFT: 288px; POSITION: absolute; TOP:
120px"

runat="server"> </asp:TextBox>
</form>
</body>
</HTML>

Thanks,

Tap

-----Original Message-----
Aye it is set alright.

The SelectedValue is not a property of the listbox?
-----Original Message-----
Is the ListBox's AutoPostBack property set to True?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
The more I learn, the less I know.

"yop" <yo*@oceanfree. net> wrote in message
news:04****** *************** *******@phx.gbl ...
Kevin

I have an item selected alright, daft idea but could it
be something to do with postback or something?

I click on the item and call the following:

Private Sub lstUsers_Select edIndexChanged( ByVal senderAs Object, ByVal e As System.EventArg s) _
HandleslstUsers.Selec tedIndexChanged
'Need to bind the textboxes from the choice picked out
from the list
UserName.Text = lstUsers.Select edItem.Text
thanks

>-----Original Message-----
>Unless an Item has been selected, this value will be
null.
>
>--
>HTH,
>
>Kevin Spencer
>Microsoft MVP
>..Net Developer
>http://www.takempis.com
>The more I learn, the less I know.
>
>"yop" <yo*@oceanfree. net> wrote in message
>news:0a******* *************** ******@phx.gbl. ..
>> All
>>
>> When I try to get the text from my listbox I am getan >> error which is listed below.
>>
>> Any ideas?
>>
>> Thanks
>>
>> Object reference not set to an instance of anobject. >> Description: An unhandled exception occurred duringthe >> execution of the current web request. Please reviewthe >> stack trace for more information about the error and
>> where it originated in the code.
>>
>> Exception Details: System.NullRefe renceException:
Object
>> reference not set to an instance of an object.
>>
>> Source Error:
>>
>>
>> Line 83: 'Need to bind the textboxes fromthe >> choice picked out from the list
>> Line 84: ' Dim ListItem As ListItem =
>> lstUsers.Select edItem
>> Line 85: UserName.Text =
stUsers.Selecte dItem.Text
>> Line 86:
>> Line 87: 'Get the user details and fill
textboxes
>>
>> Source File: C:\Dev\Asset Register
>> SW\SourceCode\D otNet\ASP.NET\A SP.NET Asset
>> Register\AssetR egister\ViewUse rs.aspx.vb Line: 85
>>
>> Stack Trace:
>>
>>
>> [NullReferenceEx ception: Object reference not setto an >> instance of an object.]
>>AssetRegister. ViewUser.lstUse rs_SelectedInde xChanged >> (Object sender, EventArgs e) in C:\Dev\AssetRegister >> SW\SourceCode\D otNet\ASP.NET\A SP.NET Asset
>> Register\AssetR egister\ViewUse rs.aspx.vb:85
>>
>>
System.Web.UI. WebControls.Lis tControl.OnSele ctedIndexChang >> ed(EventArgs e)
>>
>>
System.Web.UI. WebControls.Lis tBox.System.Web .UI.IPostBackD >> ataHandler.Rais ePostDataChange dEvent()
>> System.Web.UI.P age.RaiseChange dEvents()
>> System.Web.UI.P age.ProcessRequ estMain()
>>
>>
>>
>>
>>
>
>
>.
>

.

.

Nov 17 '05 #7
yop
No the listbox is added at design time but the items are
added from the DB at run time. Maybe that is an issue.
Extremely frustating!! :(

Also the selectedvalue property is telling it is "not a
member of System.Web.UI.W ebControls.List box.

I am using Framework 1.1, there is an issue with using
the webcontrols and this version I think??

Would I be better of using a 3rd party list or data list
or something?

-----Original Message-----
Yes it is a property. Here is the code that works fine onmy machine.....

Code behind >>>>>

Private Sub ListBox1_Select edIndexChanged( ByVal sender As System.Object, ByVal e As System.EventArg s)
Handles ListBox1.Select edIndexChanged
TextBox1.Text = ListBox1.Select edValue()
End Sub

ASPX code >>>>>

<HTML>
<HEAD>
<title>WebForm1 </title>
<meta name="GENERATOR " content="Micros oft
Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" content="VisualBasic .NET 7.1">
<meta name="vs_defaul tClientScript"
content="JavaS cript">
<meta name="vs_target Schema"
content="htt p://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form id="Form1" method="post"
runat="server" >
<asp:ListBox id="ListBox1"
style="Z-INDEX: 101; LEFT: 288px; POSITION: absolute; TOP:168px"
runat="server"
Width="160px " Height="168px" AutoPostBack="T rue">
<asp:ListItem
Value="Tapasvi ">Tapasvi</asp:ListItem>
<asp:ListItem Value="Tap
at Work">Tap at Work</asp:ListItem>
</asp:ListBox>
<asp:TextBox id="TextBox1"
style="Z-INDEX: 102; LEFT: 288px; POSITION: absolute; TOP:120px"

runat="server"> </asp:TextBox>
</form>
</body>
</HTML>

Thanks,

Tap

-----Original Message-----
Aye it is set alright.

The SelectedValue is not a property of the listbox?
-----Original Message-----
Is the ListBox's AutoPostBack property set to True?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
The more I learn, the less I know.

"yop" <yo*@oceanfree. net> wrote in message
news:04***** *************** ********@phx.gb l...
Kevin

I have an item selected alright, daft idea but could it be something to do with postback or something?

I click on the item and call the following:

Private Sub lstUsers_Select edIndexChanged( ByVal sender
As
Object, ByVal e As System.EventArg s) _
Handles

lstUsers.Sele ctedIndexChange d

'Need to bind the textboxes from the choice picked
out from the list
UserName.Text = lstUsers.Select edItem.Text
thanks

>-----Original Message-----
>Unless an Item has been selected, this value will be
null.
>
>--
>HTH,
>
>Kevin Spencer
>Microsoft MVP
>..Net Developer
>http://www.takempis.com
>The more I learn, the less I know.
>
>"yop" <yo*@oceanfree. net> wrote in message
>news:0a******* *************** ******@phx.gbl. ..
>> All
>>
>> When I try to get the text from my listbox I am get
an
>> error which is listed below.
>>
>> Any ideas?
>>
>> Thanks
>>
>> Object reference not set to an instance of an

object.
>> Description: An unhandled exception occurred
duringthe
>> execution of the current web request. Please
reviewthe
>> stack trace for more information about the error

and >> where it originated in the code.
>>
>> Exception Details: System.NullRefe renceException:
Object
>> reference not set to an instance of an object.
>>
>> Source Error:
>>
>>
>> Line 83: 'Need to bind the textboxes from

the
>> choice picked out from the list
>> Line 84: ' Dim ListItem As ListItem =
>> lstUsers.Select edItem
>> Line 85: UserName.Text =
stUsers.Selecte dItem.Text
>> Line 86:
>> Line 87: 'Get the user details and fill
textboxes
>>
>> Source File: C:\Dev\Asset Register
>> SW\SourceCode\D otNet\ASP.NET\A SP.NET Asset
>> Register\AssetR egister\ViewUse rs.aspx.vb Line: 85 >>
>> Stack Trace:
>>
>>
>> [NullReferenceEx ception: Object reference not set

to an
>> instance of an object.]
>>

AssetRegister .ViewUser.lstUs ers_SelectedInd exChanged
>> (Object sender, EventArgs e) in C:\Dev\Asset

Register
>> SW\SourceCode\D otNet\ASP.NET\A SP.NET Asset
>> Register\AssetR egister\ViewUse rs.aspx.vb:85
>>
>>

System.Web.UI .WebControls.Li stControl.OnSel ectedIndexCha

ng
>> ed(EventArgs e)
>>
>>

System.Web.UI .WebControls.Li stBox.System.We b.UI.IPostBac kD
>> ataHandler.Rais ePostDataChange dEvent()
>> System.Web.UI.P age.RaiseChange dEvents()
>> System.Web.UI.P age.ProcessRequ estMain()
>>
>>
>>
>>
>>
>
>
>.
>
.

.

.

Nov 17 '05 #8
yop
No the listbox is added at design time but the items are
added from the DB at run time. Maybe that is an issue.
Extremely frustating!! :(

Also the selectedvalue property is telling it is "not a
member of System.Web.UI.W ebControls.List box.

I am using Framework 1.1, there is an issue with using
the webcontrols and this version I think??

Would I be better of using a 3rd party list or data list
or something?

-----Original Message-----
Yes it is a property. Here is the code that works fine onmy machine.....

Code behind >>>>>

Private Sub ListBox1_Select edIndexChanged( ByVal sender As System.Object, ByVal e As System.EventArg s)
Handles ListBox1.Select edIndexChanged
TextBox1.Text = ListBox1.Select edValue()
End Sub

ASPX code >>>>>

<HTML>
<HEAD>
<title>WebForm1 </title>
<meta name="GENERATOR " content="Micros oft
Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" content="VisualBasic .NET 7.1">
<meta name="vs_defaul tClientScript"
content="JavaS cript">
<meta name="vs_target Schema"
content="htt p://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form id="Form1" method="post"
runat="server" >
<asp:ListBox id="ListBox1"
style="Z-INDEX: 101; LEFT: 288px; POSITION: absolute; TOP:168px"
runat="server"
Width="160px " Height="168px" AutoPostBack="T rue">
<asp:ListItem
Value="Tapasvi ">Tapasvi</asp:ListItem>
<asp:ListItem Value="Tap
at Work">Tap at Work</asp:ListItem>
</asp:ListBox>
<asp:TextBox id="TextBox1"
style="Z-INDEX: 102; LEFT: 288px; POSITION: absolute; TOP:120px"

runat="server"> </asp:TextBox>
</form>
</body>
</HTML>

Thanks,

Tap

-----Original Message-----
Aye it is set alright.

The SelectedValue is not a property of the listbox?
-----Original Message-----
Is the ListBox's AutoPostBack property set to True?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
The more I learn, the less I know.

"yop" <yo*@oceanfree. net> wrote in message
news:04***** *************** ********@phx.gb l...
Kevin

I have an item selected alright, daft idea but could it be something to do with postback or something?

I click on the item and call the following:

Private Sub lstUsers_Select edIndexChanged( ByVal sender
As
Object, ByVal e As System.EventArg s) _
Handles

lstUsers.Sele ctedIndexChange d

'Need to bind the textboxes from the choice picked
out from the list
UserName.Text = lstUsers.Select edItem.Text
thanks

>-----Original Message-----
>Unless an Item has been selected, this value will be
null.
>
>--
>HTH,
>
>Kevin Spencer
>Microsoft MVP
>..Net Developer
>http://www.takempis.com
>The more I learn, the less I know.
>
>"yop" <yo*@oceanfree. net> wrote in message
>news:0a******* *************** ******@phx.gbl. ..
>> All
>>
>> When I try to get the text from my listbox I am get
an
>> error which is listed below.
>>
>> Any ideas?
>>
>> Thanks
>>
>> Object reference not set to an instance of an

object.
>> Description: An unhandled exception occurred
duringthe
>> execution of the current web request. Please
reviewthe
>> stack trace for more information about the error

and >> where it originated in the code.
>>
>> Exception Details: System.NullRefe renceException:
Object
>> reference not set to an instance of an object.
>>
>> Source Error:
>>
>>
>> Line 83: 'Need to bind the textboxes from

the
>> choice picked out from the list
>> Line 84: ' Dim ListItem As ListItem =
>> lstUsers.Select edItem
>> Line 85: UserName.Text =
stUsers.Selecte dItem.Text
>> Line 86:
>> Line 87: 'Get the user details and fill
textboxes
>>
>> Source File: C:\Dev\Asset Register
>> SW\SourceCode\D otNet\ASP.NET\A SP.NET Asset
>> Register\AssetR egister\ViewUse rs.aspx.vb Line: 85 >>
>> Stack Trace:
>>
>>
>> [NullReferenceEx ception: Object reference not set

to an
>> instance of an object.]
>>

AssetRegister .ViewUser.lstUs ers_SelectedInd exChanged
>> (Object sender, EventArgs e) in C:\Dev\Asset

Register
>> SW\SourceCode\D otNet\ASP.NET\A SP.NET Asset
>> Register\AssetR egister\ViewUse rs.aspx.vb:85
>>
>>

System.Web.UI .WebControls.Li stControl.OnSel ectedIndexCha

ng
>> ed(EventArgs e)
>>
>>

System.Web.UI .WebControls.Li stBox.System.We b.UI.IPostBac kD
>> ataHandler.Rais ePostDataChange dEvent()
>> System.Web.UI.P age.RaiseChange dEvents()
>> System.Web.UI.P age.ProcessRequ estMain()
>>
>>
>>
>>
>>
>
>
>.
>
.

.

.

Nov 17 '05 #9
yop
eventually found the fix after trawling the forums!!

"I was loading the listbox dynamically on the page_load
event.
Eventually I discovered - that was too late,
The items showed on the page but weren't really
there..... (figure that one
out)
When I moved the list populate routine to the page_init
event everything
worked great."

Thanks for all your help
-----Original Message-----
All

When I try to get the text from my listbox I am get an
error which is listed below.

Any ideas?

Thanks

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.NullRefe renceException: Object
reference not set to an instance of an object.

Source Error:
Line 83: 'Need to bind the textboxes from the
choice picked out from the list
Line 84: ' Dim ListItem As ListItem =
lstUsers.Selec tedItem
Line 85: UserName.Text = stUsers.Selecte dItem.TextLine 86:
Line 87: 'Get the user details and fill textboxes

Source File: C:\Dev\Asset Register
SW\SourceCode\ DotNet\ASP.NET\ ASP.NET Asset
Register\Asset Register\ViewUs ers.aspx.vb Line: 85

Stack Trace:
[NullReferenceEx ception: Object reference not set to an
instance of an object.]
AssetRegister.V iewUser.lstUser s_SelectedIndex Changed
(Object sender, EventArgs e) in C:\Dev\Asset Register
SW\SourceCode\ DotNet\ASP.NET\ ASP.NET Asset
Register\Asset Register\ViewUs ers.aspx.vb:85

System.Web.UI. WebControls.Lis tControl.OnSele ctedIndexChan ged(EventArgs e)

System.Web.UI. WebControls.Lis tBox.System.Web .UI.IPostBack DataHandler.Rai sePostDataChang edEvent()
System.Web.UI.P age.RaiseChange dEvents()
System.Web.UI.P age.ProcessRequ estMain()

.

Nov 17 '05 #10

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

Similar topics

5
1280
by: Ben | last post by:
Hi, I seem to be having a memory management issue with the ListBox control. Using .NET Memory Profiler, the Clear() method does not appear to actually remove references to objects in the list box immediately. I have been able to work around this by clearing the box, adding a dummy string entry, and then clearing it again. Here is some code to demonstrate this:
1
3848
by: jarit | last post by:
Hi, Found these coding guidelines for C#, HTML, Javascript, Java, HTML, PL/SQL, T-SQL, VB and VBScript. Well written and free to download. www.demachina.com/products/swat Jeroen
6
2876
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset a denormalized mirror of the database, but I'm not having much luck getting the selection logic down (I haven't found a 'hook' where I can access the listbox object as an object to set the listitem's selected property before it gets rendered).. ...
1
5314
by: Sachin Kuchinad | last post by:
Hi All I am using .NET Framework version 1.0.3705 to build a website. Now i have made a webform and on that i have added a dropdown to the page I bind this listbox to a datareader . This does not happenm , i have no clue what the problem is I am attaching the error <font color='red' >
2
3843
by: tangokilo | last post by:
Hello and thanks for your help, I have the following Listbox created in VisualStudio 2003 designer, desiring to select multiple entries from that list: ------------------------------- ListBoxUser.Location = New System.Drawing.Point(16, 240) ListBoxUser.Name = "ListBoxUser" ListBoxUser.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended ListBoxUser.Size = New System.Drawing.Size(136, 147) ListBoxUser.TabIndex = 6
3
5110
by: Brent | last post by:
I'm trying to open and manipulate an Excel spreadsheet from C#. To that end, I've referenced Interop.EXCEL9.dll, which I have on my machine. All of the examples I've read say to do something like this: -------------------------- Excel.Application xl = new Excel.ApplicationClass(); xl.Visible = "true"; String workbookPath = @"c:\SomeWorkBook.xls"; Excel.Workbook xlW = xlW.Workbooks.Open(workbookPath,0, false, 5, "",
2
9799
by: Pat | last post by:
I'm a newbie to c# and could use some help - been banging my head on the keyboard for 3 days now. I have an unbound listbox that I'm populating this way: 1. loop through a datatable and load row into row object 2. Check one of the row columns against a dictionary key 3. If it's found, add it to the listbox. Then I want to pass the actual item that shows up in the listbox
4
4233
by: rn5a | last post by:
I have a ListBox which should list all the files & directories that exist in a particular directory. The problem is I can get the ListBox to list either all the files or all the directories but not the 2 of them together. This is what I tried: Sub Page_Load(.....) Dim dInfo As DirectoryInfo dInfo = New DirectoryInfo(Server.MapPath(MyDir))
1
1986
by: John | last post by:
Using Access 2007 I find that, on opening a form, a listbox control always displays one of the values in the list, even if no value has been selected. Thus, the first value in the list is displayed (without highlighting) when the field has a null value. The user may then change the displayed value by clicking on the up or down arrow to the right of the control. This newly displayed value will also be without highlighting and will be...
0
8903
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
8758
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9422
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9277
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9198
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9130
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4524
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3236
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2663
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.