470,586 Members | 1,707 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,586 developers. It's quick & easy.

Data binding in TextBox after dropdown list indexchanged

I have a question in the following. Any one could give me a help?
Thanks
David

The dataset is declared and created at Class level. My source code is here:

Private Sub lstPatientID_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles lstPatientID.SelectedIndexChanged
txtDebug.Text &= lstPatientID.SelectedIndex.ToString
txtDebug.Text &= lstPatientID.SelectedIndex.ToString
txtLastName.Text =
ds.Tables("Patients").Rows(lstPatientID.SelectedIn dex)("LastName")

When Page_load,
I use Dropdown list index to set all textboses. Now select another item in
Dropdown list, I got the following error at Line 323:

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

Source Error:
Line 321: txtDebug.Text &= lstPatientID.SelectedIndex.ToString
Line 322: txtDebug.Text &= lstPatientID.SelectedIndex.ToString
Line 323: txtLastName.Text =
ds.Tables("Patients").Rows(lstPatientID.SelectedIn dex)("LastName")

Line: 323
Nov 19 '05 #1
5 3245
txtLastName is null, ds is null or there's no table named "Patients"....we
can't tell which it is, but one of those is true...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"david" <da***@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com...
I have a question in the following. Any one could give me a help?
Thanks
David

The dataset is declared and created at Class level. My source code is here:
Private Sub lstPatientID_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstPatientID.SelectedIndexChanged
txtDebug.Text &= lstPatientID.SelectedIndex.ToString
txtDebug.Text &= lstPatientID.SelectedIndex.ToString
txtLastName.Text =
ds.Tables("Patients").Rows(lstPatientID.SelectedIn dex)("LastName")

When Page_load,
I use Dropdown list index to set all textboses. Now select another item in
Dropdown list, I got the following error at Line 323:

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

Source Error:
Line 321: txtDebug.Text &= lstPatientID.SelectedIndex.ToString
Line 322: txtDebug.Text &= lstPatientID.SelectedIndex.ToString
Line 323: txtLastName.Text =
ds.Tables("Patients").Rows(lstPatientID.SelectedIn dex)("LastName")

Line: 323

Nov 19 '05 #2
ds is a DataSet.
ds.Tables(0) should be ds.Tables("Patients")
"LastName" is the colunm name.
When Page is first loaded, it OK.
That ocurs when I select a new item of dropdown list.
It is supporsed to bind a new set of data display in all other textbox.
Does it mean the dataset ds has disappeared?

Thanks

David

"Karl Seguin" wrote:
txtLastName is null, ds is null or there's no table named "Patients"....we
can't tell which it is, but one of those is true...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"david" <da***@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com...
I have a question in the following. Any one could give me a help?
Thanks
David

The dataset is declared and created at Class level. My source code is

here:

Private Sub lstPatientID_SelectedIndexChanged(ByVal sender As

System.Object,
ByVal e As System.EventArgs) Handles lstPatientID.SelectedIndexChanged
txtDebug.Text &= lstPatientID.SelectedIndex.ToString
txtDebug.Text &= lstPatientID.SelectedIndex.ToString
txtLastName.Text =
ds.Tables("Patients").Rows(lstPatientID.SelectedIn dex)("LastName")

When Page_load,
I use Dropdown list index to set all textboses. Now select another item in
Dropdown list, I got the following error at Line 323:

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

Source Error:
Line 321: txtDebug.Text &= lstPatientID.SelectedIndex.ToString
Line 322: txtDebug.Text &= lstPatientID.SelectedIndex.ToString
Line 323: txtLastName.Text =
ds.Tables("Patients").Rows(lstPatientID.SelectedIn dex)("LastName")

Line: 323


Nov 19 '05 #3
ds wont' automatically survive a postback....are you repopulating it on
postback? Storing it somewhere?

If you have vs.net 2003, debug and step through the code...see what is
null...no point in trying to solve all 3 potential problems until we know
which it is..

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"david" <da***@discussions.microsoft.com> wrote in message
news:B6**********************************@microsof t.com...
ds is a DataSet.
ds.Tables(0) should be ds.Tables("Patients")
"LastName" is the colunm name.
When Page is first loaded, it OK.
That ocurs when I select a new item of dropdown list.
It is supporsed to bind a new set of data display in all other textbox.
Does it mean the dataset ds has disappeared?

Thanks

David

"Karl Seguin" wrote:
txtLastName is null, ds is null or there's no table named "Patients"....we can't tell which it is, but one of those is true...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"david" <da***@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com...
I have a question in the following. Any one could give me a help?
Thanks
David

The dataset is declared and created at Class level. My source code is

here:

Private Sub lstPatientID_SelectedIndexChanged(ByVal sender As

System.Object,
ByVal e As System.EventArgs) Handles lstPatientID.SelectedIndexChanged
txtDebug.Text &= lstPatientID.SelectedIndex.ToString
txtDebug.Text &= lstPatientID.SelectedIndex.ToString
txtLastName.Text =
ds.Tables("Patients").Rows(lstPatientID.SelectedIn dex)("LastName")

When Page_load,
I use Dropdown list index to set all textboses. Now select another item in Dropdown list, I got the following error at Line 323:

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

Source Error:
Line 321: txtDebug.Text &= lstPatientID.SelectedIndex.ToString
Line 322: txtDebug.Text &= lstPatientID.SelectedIndex.ToString
Line 323: txtLastName.Text =
ds.Tables("Patients").Rows(lstPatientID.SelectedIn dex)("LastName")

Line: 323


Nov 19 '05 #4
Thank you very much.
How to store the dataset as for a postback?
I have .NET 2003. But I never use the debugging tool.

David

"Karl Seguin" wrote:
ds wont' automatically survive a postback....are you repopulating it on
postback? Storing it somewhere?

If you have vs.net 2003, debug and step through the code...see what is
null...no point in trying to solve all 3 potential problems until we know
which it is..

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"david" <da***@discussions.microsoft.com> wrote in message
news:B6**********************************@microsof t.com...
ds is a DataSet.
ds.Tables(0) should be ds.Tables("Patients")
"LastName" is the colunm name.
When Page is first loaded, it OK.
That ocurs when I select a new item of dropdown list.
It is supporsed to bind a new set of data display in all other textbox.
Does it mean the dataset ds has disappeared?

Thanks

David

"Karl Seguin" wrote:
txtLastName is null, ds is null or there's no table named "Patients"....we can't tell which it is, but one of those is true...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"david" <da***@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com...
> I have a question in the following. Any one could give me a help?
> Thanks
> David
>
> The dataset is declared and created at Class level. My source code is
here:
>
> Private Sub lstPatientID_SelectedIndexChanged(ByVal sender As
System.Object,
> ByVal e As System.EventArgs) Handles lstPatientID.SelectedIndexChanged
> txtDebug.Text &= lstPatientID.SelectedIndex.ToString
> txtDebug.Text &= lstPatientID.SelectedIndex.ToString
> txtLastName.Text =
> ds.Tables("Patients").Rows(lstPatientID.SelectedIn dex)("LastName")
>
> When Page_load,
> I use Dropdown list index to set all textboses. Now select another item in > Dropdown list, I got the following error at Line 323:
>
> Exception Details: System.NullReferenceException: Object reference not set > to an instance of an object.
>
> Source Error:
> Line 321: txtDebug.Text &= lstPatientID.SelectedIndex.ToString
> Line 322: txtDebug.Text &= lstPatientID.SelectedIndex.ToString
> Line 323: txtLastName.Text =
> ds.Tables("Patients").Rows(lstPatientID.SelectedIn dex)("LastName")
>
> Line: 323
>
>


Nov 19 '05 #5
David, left click on the left-side column of VS.Net, a red dot should
appear...that's a breakpoint...Alternatively, you can put your cursor on a
line, goto "Debug" --> "New Breakpoint". Now, hit f5 or "Debug" -->
"Start" which should build and start up your application, launching
IE...now you can browse your site as always, but when the code execution
hits any line with a breakpoint, it'll stop at that line...you can use f10
and f11to step over/in functions/lines....you can add "watches" to
values...play with it...you won't regret it...

You either have to reload the dataset, or store it in the Cache or Session
or some place...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"david" <da***@discussions.microsoft.com> wrote in message
news:33**********************************@microsof t.com...
Thank you very much.
How to store the dataset as for a postback?
I have .NET 2003. But I never use the debugging tool.

David

"Karl Seguin" wrote:
ds wont' automatically survive a postback....are you repopulating it on
postback? Storing it somewhere?

If you have vs.net 2003, debug and step through the code...see what is
null...no point in trying to solve all 3 potential problems until we know which it is..

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"david" <da***@discussions.microsoft.com> wrote in message
news:B6**********************************@microsof t.com...
ds is a DataSet.
ds.Tables(0) should be ds.Tables("Patients")
"LastName" is the colunm name.
When Page is first loaded, it OK.
That ocurs when I select a new item of dropdown list.
It is supporsed to bind a new set of data display in all other textbox. Does it mean the dataset ds has disappeared?

Thanks

David

"Karl Seguin" wrote:

> txtLastName is null, ds is null or there's no table named

"Patients"....we
> can't tell which it is, but one of those is true...
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/ - New and Improved (yes, the popup is
> annoying)
> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to > come!)
> "david" <da***@discussions.microsoft.com> wrote in message
> news:97**********************************@microsof t.com...
> > I have a question in the following. Any one could give me a help?
> > Thanks
> > David
> >
> > The dataset is declared and created at Class level. My source code is > here:
> >
> > Private Sub lstPatientID_SelectedIndexChanged(ByVal sender As
> System.Object,
> > ByVal e As System.EventArgs) Handles lstPatientID.SelectedIndexChanged > > txtDebug.Text &= lstPatientID.SelectedIndex.ToString
> > txtDebug.Text &= lstPatientID.SelectedIndex.ToString
> > txtLastName.Text =
> > ds.Tables("Patients").Rows(lstPatientID.SelectedIn dex)("LastName")
> >
> > When Page_load,
> > I use Dropdown list index to set all textboses. Now select another

item in
> > Dropdown list, I got the following error at Line 323:
> >
> > Exception Details: System.NullReferenceException: Object reference not
set
> > to an instance of an object.
> >
> > Source Error:
> > Line 321: txtDebug.Text &=

lstPatientID.SelectedIndex.ToString > > Line 322: txtDebug.Text &= lstPatientID.SelectedIndex.ToString > > Line 323: txtLastName.Text =
> > ds.Tables("Patients").Rows(lstPatientID.SelectedIn dex)("LastName")
> >
> > Line: 323
> >
> >
>
>
>


Nov 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by KCT | last post: by
reply views Thread by ba | last post: by
1 post views Thread by goodwill | last post: by
2 posts views Thread by Lori Markle via .NET 247 | last post: by
1 post views Thread by Jerome | last post: by
1 post views Thread by Danny Ni | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.