Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Data binding in TextBox after dropdown list indexchanged

Reply
Thread Tools

Data binding in TextBox after dropdown list indexchanged

 
 
=?Utf-8?B?ZGF2aWQ=?=
Guest
Posts: n/a
 
      04-01-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.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


 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      04-01-2005
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:(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.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
>
>



 
Reply With Quote
 
 
 
 
=?Utf-8?B?ZGF2aWQ=?=
Guest
Posts: n/a
 
      04-01-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:(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.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
> >
> >

>
>
>

 
Reply With Quote
 
Karl Seguin
Guest
Posts: n/a
 
      04-01-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:(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:(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.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
> > >
> > >

> >
> >
> >



 
Reply With Quote
 
=?Utf-8?B?ZGF2aWQ=?=
Guest
Posts: n/a
 
      04-01-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:(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:(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.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
> > > >
> > > >
> > >
> > >
> > >

>
>
>

 
Reply With Quote
 
Karl Seguin
Guest
Posts: n/a
 
      04-04-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:(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:(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:(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.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
> > > > >
> > > > >
> > > >
> > > >
> > > >

> >
> >
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools

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
cannot select two-way data binding property on a dropdown list con Mike Milian ASP .Net 0 04-14-2008 02:49 AM
DropDownList - IndexChanged mosscliffe ASP .Net 2 06-19-2006 06:27 PM
Binding dataset to a Dropdown list Fraggle_Rock_1@yahoo.com ASP .Net 2 09-14-2004 11:36 AM
Dropdown List data binding Binod Nair ASP .Net 3 01-16-2004 09:14 PM
HELP - Fill Datagrid2 from indexchanged in Datagrid1 Jim Mitchell ASP .Net Datagrid Control 0 08-17-2003 01:38 AM



Advertisments