PC Review


Reply
Thread Tools Rate Thread

Data binding in TextBox after dropdown list indexchanged

 
 
=?Utf-8?B?ZGF2aWQ=?=
Guest
Posts: n/a
 
      1st Apr 2005
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.SelectedIndex)("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.SelectedIndex)("LastName")

Line: 323


 
Reply With Quote
 
 
 
 
=?Utf-8?B?ZGF2aWQ=?=
Guest
Posts: n/a
 
      1st Apr 2005
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" <(E-Mail Removed)> wrote in message
> news:97AF5BFC-0148-481F-B4B0-(E-Mail Removed)...
> > 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.SelectedIndex)("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.SelectedIndex)("LastName")
> >
> > Line: 323
> >
> >

>
>
>

 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      1st Apr 2005
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" <(E-Mail Removed)> wrote in message
news:B6C92D9B-5EA4-40AF-86E1-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> > news:97AF5BFC-0148-481F-B4B0-(E-Mail Removed)...
> > > 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.SelectedIndex)("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.SelectedIndex)("LastName")
> > >
> > > Line: 323
> > >
> > >

> >
> >
> >



 
Reply With Quote
 
=?Utf-8?B?ZGF2aWQ=?=
Guest
Posts: n/a
 
      2nd Apr 2005
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" <(E-Mail Removed)> wrote in message
> news:B6C92D9B-5EA4-40AF-86E1-(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > > news:97AF5BFC-0148-481F-B4B0-(E-Mail Removed)...
> > > > 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.SelectedIndex)("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.SelectedIndex)("LastName")
> > > >
> > > > Line: 323
> > > >
> > > >
> > >
> > >
> > >

>
>
>

 
Reply With Quote
 
Karl Seguin
Guest
Posts: n/a
 
      4th Apr 2005
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" <(E-Mail Removed)> wrote in message
news:33F85FAE-AADC-4A34-BDAA-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> > news:B6C92D9B-5EA4-40AF-86E1-(E-Mail Removed)...
> > > 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" <(E-Mail Removed)> wrote in message
> > > > news:97AF5BFC-0148-481F-B4B0-(E-Mail Removed)...
> > > > > 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.SelectedIndex)("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.SelectedIndex)("LastName")
> > > > >
> > > > > Line: 323
> > > > >
> > > > >
> > > >
> > > >
> > > >

> >
> >
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dropdown list determined by another dropdown list Wackyracer Microsoft Excel Misc 5 27th Apr 2009 10:49 PM
result of selecting from the dropdown list should be a dropdown list No News Microsoft Excel Worksheet Functions 1 1st Jul 2006 09:20 AM
DropDownList - IndexChanged mosscliffe Microsoft ASP .NET 2 19th Jun 2006 07:27 PM
TabControl IndexChanged - MsgBox and Save Record? theintrepidfox@hotmail.com Microsoft Dot NET 0 9th Jul 2005 03:58 AM
threading, what different between DataGrid Binding to Binding TextBox mttc Microsoft Dot NET Framework Forms 3 19th Nov 2004 09:33 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:50 PM.