473,320 Members | 1,887 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Problems wit Databinding to a DropDown box

Hello,

I have done the following to bind data to a DropDown box:

1. Drag SQLServer table onto web form to create data connection and data
adapter.

2. Generate dataset by right-clicking on the data adapter ad selecting
generate dataset.

3. Setting the drop down box propertied to reflect so that:

Datasource = Dataset11
Datamember = table
Datatextfield = tablerow
Datavaluefield = tablerow

When I run the application I don't generate any errors, but no data is
present in the DropDown box...Well, actually I get a drop down that is
blank.

Any ideas an what Imay be doing wrong?

Also, if I code the information, can I put it in the CodeBehind file or does
it have to be in the actual ASPX?

Thanks in advance,
Kris
Nov 18 '05 #1
11 1588
Did you call the .DataBind method of the DropDown box?
"Kris Rockwell" <kr***************************@hybrid-learning.com> wrote in
message news:Od**************@TK2MSFTNGP09.phx.gbl...
Hello,

I have done the following to bind data to a DropDown box:

1. Drag SQLServer table onto web form to create data connection and data
adapter.

2. Generate dataset by right-clicking on the data adapter ad selecting
generate dataset.

3. Setting the drop down box propertied to reflect so that:

Datasource = Dataset11
Datamember = table
Datatextfield = tablerow
Datavaluefield = tablerow

When I run the application I don't generate any errors, but no data is
present in the DropDown box...Well, actually I get a drop down that is
blank.

Any ideas an what Imay be doing wrong?

Also, if I code the information, can I put it in the CodeBehind file or does it have to be in the actual ASPX?

Thanks in advance,
Kris

Nov 18 '05 #2
I haven't explicitly called it in the code, but I have set it in the
Property page of the DropDown Box.

I did try it though and still got no results. It is strange, though...The
box seems populated in that I can drop it down, but there is no content as
there should be.

Kris
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:#K**************@TK2MSFTNGP09.phx.gbl...
Did you call the .DataBind method of the DropDown box?
"Kris Rockwell" <kr***************************@hybrid-learning.com> wrote in message news:Od**************@TK2MSFTNGP09.phx.gbl...
Hello,

I have done the following to bind data to a DropDown box:

1. Drag SQLServer table onto web form to create data connection and data
adapter.

2. Generate dataset by right-clicking on the data adapter ad selecting
generate dataset.

3. Setting the drop down box propertied to reflect so that:

Datasource = Dataset11
Datamember = table
Datatextfield = tablerow
Datavaluefield = tablerow

When I run the application I don't generate any errors, but no data is
present in the DropDown box...Well, actually I get a drop down that is
blank.

Any ideas an what Imay be doing wrong?

Also, if I code the information, can I put it in the CodeBehind file or

does
it have to be in the actual ASPX?

Thanks in advance,
Kris


Nov 18 '05 #3
You can't call the DataBind method (or any method of any object for that
matter) via the design-time property box. It must be called from code. The
fact that the box drops down with noting in it is what all drop down boxes
that don't have data in them do.

Let's see your entire Page_Load event handler.
"Kris Rockwell" <kr***************************@hybrid-learning.com> wrote in
message news:eD**************@TK2MSFTNGP12.phx.gbl...
I haven't explicitly called it in the code, but I have set it in the
Property page of the DropDown Box.

I did try it though and still got no results. It is strange, though...The
box seems populated in that I can drop it down, but there is no content as
there should be.

Kris
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:#K**************@TK2MSFTNGP09.phx.gbl...
Did you call the .DataBind method of the DropDown box?
"Kris Rockwell" <kr***************************@hybrid-learning.com> wrote
in
message news:Od**************@TK2MSFTNGP09.phx.gbl...
Hello,

I have done the following to bind data to a DropDown box:

1. Drag SQLServer table onto web form to create data connection and data adapter.

2. Generate dataset by right-clicking on the data adapter ad selecting
generate dataset.

3. Setting the drop down box propertied to reflect so that:

Datasource = Dataset11
Datamember = table
Datatextfield = tablerow
Datavaluefield = tablerow

When I run the application I don't generate any errors, but no data is
present in the DropDown box...Well, actually I get a drop down that is
blank.

Any ideas an what Imay be doing wrong?

Also, if I code the information, can I put it in the CodeBehind file

or does
it have to be in the actual ASPX?

Thanks in advance,
Kris



Nov 18 '05 #4
Here is the code:

Sub Page_Load
cbACType.DataBind()
End Sub

The database connection information is in my CodeBehind vb file.

Regards,
Kris
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:#Y**************@TK2MSFTNGP12.phx.gbl...
You can't call the DataBind method (or any method of any object for that
matter) via the design-time property box. It must be called from code. The fact that the box drops down with noting in it is what all drop down boxes
that don't have data in them do.

Let's see your entire Page_Load event handler.
"Kris Rockwell" <kr***************************@hybrid-learning.com> wrote in message news:eD**************@TK2MSFTNGP12.phx.gbl...
I haven't explicitly called it in the code, but I have set it in the
Property page of the DropDown Box.

I did try it though and still got no results. It is strange, though...The
box seems populated in that I can drop it down, but there is no content as there should be.

Kris
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:#K**************@TK2MSFTNGP09.phx.gbl...
Did you call the .DataBind method of the DropDown box?
"Kris Rockwell" <kr***************************@hybrid-learning.com>

wrote
in
message news:Od**************@TK2MSFTNGP09.phx.gbl...
> Hello,
>
> I have done the following to bind data to a DropDown box:
>
> 1. Drag SQLServer table onto web form to create data connection and

data > adapter.
>
> 2. Generate dataset by right-clicking on the data adapter ad selecting > generate dataset.
>
> 3. Setting the drop down box propertied to reflect so that:
>
> Datasource = Dataset11
> Datamember = table
> Datatextfield = tablerow
> Datavaluefield = tablerow
>
> When I run the application I don't generate any errors, but no data is > present in the DropDown box...Well, actually I get a drop down that is > blank.
>
> Any ideas an what Imay be doing wrong?
>
> Also, if I code the information, can I put it in the CodeBehind file or does
> it have to be in the actual ASPX?
>
> Thanks in advance,
> Kris
>
>



Nov 18 '05 #5
Can we have the db connection code as well?

By the way, only call the DataBind method on the first page call (ViewState
will take care of keeping the dropdown list populated after that. So, your
page_load code should be:

Sub Page_Load
If Not IsPostBack Then
cbACType.DataBind()
End If
End Sub
"Kris Rockwell" <kr***************************@hybrid-learning.com> wrote in
message news:un**************@TK2MSFTNGP10.phx.gbl...
Here is the code:

Sub Page_Load
cbACType.DataBind()
End Sub

The database connection information is in my CodeBehind vb file.

Regards,
Kris
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:#Y**************@TK2MSFTNGP12.phx.gbl...
You can't call the DataBind method (or any method of any object for that
matter) via the design-time property box. It must be called from code. The
fact that the box drops down with noting in it is what all drop down boxes
that don't have data in them do.

Let's see your entire Page_Load event handler.
"Kris Rockwell" <kr***************************@hybrid-learning.com> wrote in
message news:eD**************@TK2MSFTNGP12.phx.gbl...
I haven't explicitly called it in the code, but I have set it in the
Property page of the DropDown Box.

I did try it though and still got no results. It is strange,
though...The box seems populated in that I can drop it down, but there is no
content as there should be.

Kris
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:#K**************@TK2MSFTNGP09.phx.gbl...
> Did you call the .DataBind method of the DropDown box?
>
>
> "Kris Rockwell" <kr***************************@hybrid-learning.com> wrote
in
> message news:Od**************@TK2MSFTNGP09.phx.gbl...
> > Hello,
> >
> > I have done the following to bind data to a DropDown box:
> >
> > 1. Drag SQLServer table onto web form to create data connection
and data
> > adapter.
> >
> > 2. Generate dataset by right-clicking on the data adapter ad selecting > > generate dataset.
> >
> > 3. Setting the drop down box propertied to reflect so that:
> >
> > Datasource = Dataset11
> > Datamember = table
> > Datatextfield = tablerow
> > Datavaluefield = tablerow
> >
> > When I run the application I don't generate any errors, but no
data is > > present in the DropDown box...Well, actually I get a drop down
that
is > > blank.
> >
> > Any ideas an what Imay be doing wrong?
> >
> > Also, if I code the information, can I put it in the CodeBehind

file or
> does
> > it have to be in the actual ASPX?
> >
> > Thanks in advance,
> > Kris
> >
> >
>
>



Nov 18 '05 #6
Well, I have kep the DB connection in the code behind page in an effort to
keep it seperate (and thus away from the eyes of curious users) from the
ASPX. In testing different methods I have deleted from the VB code at the
moment,so I will have to write it back in before I post the code. Couldn't I
use the Connection and DataAdapter objects within .NET for this?

Kris
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:#t*************@TK2MSFTNGP12.phx.gbl...
Can we have the db connection code as well?

By the way, only call the DataBind method on the first page call (ViewState will take care of keeping the dropdown list populated after that. So, your page_load code should be:

Sub Page_Load
If Not IsPostBack Then
cbACType.DataBind()
End If
End Sub
"Kris Rockwell" <kr***************************@hybrid-learning.com> wrote in message news:un**************@TK2MSFTNGP10.phx.gbl...
Here is the code:

Sub Page_Load
cbACType.DataBind()
End Sub

The database connection information is in my CodeBehind vb file.

Regards,
Kris
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:#Y**************@TK2MSFTNGP12.phx.gbl...
You can't call the DataBind method (or any method of any object for that matter) via the design-time property box. It must be called from code.
The
fact that the box drops down with noting in it is what all drop down boxes that don't have data in them do.

Let's see your entire Page_Load event handler.
"Kris Rockwell" <kr***************************@hybrid-learning.com> wrote
in
message news:eD**************@TK2MSFTNGP12.phx.gbl...
> I haven't explicitly called it in the code, but I have set it in the
> Property page of the DropDown Box.
>
> I did try it though and still got no results. It is strange,

though...The
> box seems populated in that I can drop it down, but there is no

content
as
> there should be.
>
> Kris
>
>
> "Scott M." <s-***@BADSPAMsnet.net> wrote in message
> news:#K**************@TK2MSFTNGP09.phx.gbl...
> > Did you call the .DataBind method of the DropDown box?
> >
> >
> > "Kris Rockwell"

<kr***************************@hybrid-learning.com> wrote
> in
> > message news:Od**************@TK2MSFTNGP09.phx.gbl...
> > > Hello,
> > >
> > > I have done the following to bind data to a DropDown box:
> > >
> > > 1. Drag SQLServer table onto web form to create data connection

and data
> > > adapter.
> > >
> > > 2. Generate dataset by right-clicking on the data adapter ad

selecting
> > > generate dataset.
> > >
> > > 3. Setting the drop down box propertied to reflect so that:
> > >
> > > Datasource = Dataset11
> > > Datamember = table
> > > Datatextfield = tablerow
> > > Datavaluefield = tablerow
> > >
> > > When I run the application I don't generate any errors, but no data
is
> > > present in the DropDown box...Well, actually I get a drop down

that
is
> > > blank.
> > >
> > > Any ideas an what Imay be doing wrong?
> > >
> > > Also, if I code the information, can I put it in the CodeBehind

file or
> > does
> > > it have to be in the actual ASPX?
> > >
> > > Thanks in advance,
> > > Kris
> > >
> > >
> >
> >
>
>



Nov 18 '05 #7
Well, I have kep the DB connection in the code behind page in an effort to
keep it seperate (and thus away from the eyes of curious users) from the
ASPX. In testing different methods I have deleted from the VB code at the
moment,so I will have to write it back in before I post the code. Couldn't I
use the Connection and DataAdapter objects within .NET for this?

Kris
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:#t*************@TK2MSFTNGP12.phx.gbl...
Can we have the db connection code as well?

By the way, only call the DataBind method on the first page call (ViewState will take care of keeping the dropdown list populated after that. So, your page_load code should be:

Sub Page_Load
If Not IsPostBack Then
cbACType.DataBind()
End If
End Sub
"Kris Rockwell" <kr***************************@hybrid-learning.com> wrote in message news:un**************@TK2MSFTNGP10.phx.gbl...
Here is the code:

Sub Page_Load
cbACType.DataBind()
End Sub

The database connection information is in my CodeBehind vb file.

Regards,
Kris
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:#Y**************@TK2MSFTNGP12.phx.gbl...
You can't call the DataBind method (or any method of any object for that matter) via the design-time property box. It must be called from code.
The
fact that the box drops down with noting in it is what all drop down boxes that don't have data in them do.

Let's see your entire Page_Load event handler.
"Kris Rockwell" <kr***************************@hybrid-learning.com> wrote
in
message news:eD**************@TK2MSFTNGP12.phx.gbl...
> I haven't explicitly called it in the code, but I have set it in the
> Property page of the DropDown Box.
>
> I did try it though and still got no results. It is strange,

though...The
> box seems populated in that I can drop it down, but there is no

content
as
> there should be.
>
> Kris
>
>
> "Scott M." <s-***@BADSPAMsnet.net> wrote in message
> news:#K**************@TK2MSFTNGP09.phx.gbl...
> > Did you call the .DataBind method of the DropDown box?
> >
> >
> > "Kris Rockwell"

<kr***************************@hybrid-learning.com> wrote
> in
> > message news:Od**************@TK2MSFTNGP09.phx.gbl...
> > > Hello,
> > >
> > > I have done the following to bind data to a DropDown box:
> > >
> > > 1. Drag SQLServer table onto web form to create data connection

and data
> > > adapter.
> > >
> > > 2. Generate dataset by right-clicking on the data adapter ad

selecting
> > > generate dataset.
> > >
> > > 3. Setting the drop down box propertied to reflect so that:
> > >
> > > Datasource = Dataset11
> > > Datamember = table
> > > Datatextfield = tablerow
> > > Datavaluefield = tablerow
> > >
> > > When I run the application I don't generate any errors, but no data
is
> > > present in the DropDown box...Well, actually I get a drop down

that
is
> > > blank.
> > >
> > > Any ideas an what Imay be doing wrong?
> > >
> > > Also, if I code the information, can I put it in the CodeBehind

file or
> > does
> > > it have to be in the actual ASPX?
> > >
> > > Thanks in advance,
> > > Kris
> > >
> > >
> >
> >
>
>



Nov 18 '05 #8
Kris,

All of your compiled code goes in the code-behind. That is what it is there
for. Even if you use the Visual DataAdapter and Connection controls, you
are still working with code in the code-behind. When you use those
controls, code is written for you in the code-behind, instead of you
declaring and configuring the classes yourself.

Regardless of whether or not you use the controls or write the code
yourself, we need to see your code in order to help you solve your problem.

Since all it really takes to get the DropDownList control working is to set
its DataSource and DataField properties and then to call its DataBind method
on the first page call (and you seem to have done that), we can assume that:

either your database connection is not setup correctly or
you are connecting to the db, but not retuning any data

We won't know until you provide us with everything you have.
"Kris Rockwell" <kr***************************@hybrid-learning.com> wrote in
message news:uG*************@TK2MSFTNGP09.phx.gbl...
Well, I have kep the DB connection in the code behind page in an effort to
keep it seperate (and thus away from the eyes of curious users) from the
ASPX. In testing different methods I have deleted from the VB code at the
moment,so I will have to write it back in before I post the code. Couldn't I use the Connection and DataAdapter objects within .NET for this?

Kris
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:#t*************@TK2MSFTNGP12.phx.gbl...
Can we have the db connection code as well?

By the way, only call the DataBind method on the first page call (ViewState
will take care of keeping the dropdown list populated after that. So,

your
page_load code should be:

Sub Page_Load
If Not IsPostBack Then
cbACType.DataBind()
End If
End Sub
"Kris Rockwell" <kr***************************@hybrid-learning.com> wrote in
message news:un**************@TK2MSFTNGP10.phx.gbl...
Here is the code:

Sub Page_Load
cbACType.DataBind()
End Sub

The database connection information is in my CodeBehind vb file.

Regards,
Kris
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:#Y**************@TK2MSFTNGP12.phx.gbl...
> You can't call the DataBind method (or any method of any object for that > matter) via the design-time property box. It must be called from code. The
> fact that the box drops down with noting in it is what all drop down

boxes
> that don't have data in them do.
>
> Let's see your entire Page_Load event handler.
>
>
> "Kris Rockwell" <kr***************************@hybrid-learning.com>

wrote
in
> message news:eD**************@TK2MSFTNGP12.phx.gbl...
> > I haven't explicitly called it in the code, but I have set it in the > > Property page of the DropDown Box.
> >
> > I did try it though and still got no results. It is strange,
though...The
> > box seems populated in that I can drop it down, but there is no

content
as
> > there should be.
> >
> > Kris
> >
> >
> > "Scott M." <s-***@BADSPAMsnet.net> wrote in message
> > news:#K**************@TK2MSFTNGP09.phx.gbl...
> > > Did you call the .DataBind method of the DropDown box?
> > >
> > >
> > > "Kris Rockwell" <kr***************************@hybrid-learning.com> > wrote
> > in
> > > message news:Od**************@TK2MSFTNGP09.phx.gbl...
> > > > Hello,
> > > >
> > > > I have done the following to bind data to a DropDown box:
> > > >
> > > > 1. Drag SQLServer table onto web form to create data

connection and
> data
> > > > adapter.
> > > >
> > > > 2. Generate dataset by right-clicking on the data adapter ad
selecting
> > > > generate dataset.
> > > >
> > > > 3. Setting the drop down box propertied to reflect so that:
> > > >
> > > > Datasource = Dataset11
> > > > Datamember = table
> > > > Datatextfield = tablerow
> > > > Datavaluefield = tablerow
> > > >
> > > > When I run the application I don't generate any errors, but no

data
is
> > > > present in the DropDown box...Well, actually I get a drop down

that
is
> > > > blank.
> > > >
> > > > Any ideas an what Imay be doing wrong?
> > > >
> > > > Also, if I code the information, can I put it in the
CodeBehind file
> or
> > > does
> > > > it have to be in the actual ASPX?
> > > >
> > > > Thanks in advance,
> > > > Kris
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 18 '05 #9
Kris,

All of your compiled code goes in the code-behind. That is what it is there
for. Even if you use the Visual DataAdapter and Connection controls, you
are still working with code in the code-behind. When you use those
controls, code is written for you in the code-behind, instead of you
declaring and configuring the classes yourself.

Regardless of whether or not you use the controls or write the code
yourself, we need to see your code in order to help you solve your problem.

Since all it really takes to get the DropDownList control working is to set
its DataSource and DataField properties and then to call its DataBind method
on the first page call (and you seem to have done that), we can assume that:

either your database connection is not setup correctly or
you are connecting to the db, but not retuning any data

We won't know until you provide us with everything you have.
"Kris Rockwell" <kr***************************@hybrid-learning.com> wrote in
message news:uG*************@TK2MSFTNGP09.phx.gbl...
Well, I have kep the DB connection in the code behind page in an effort to
keep it seperate (and thus away from the eyes of curious users) from the
ASPX. In testing different methods I have deleted from the VB code at the
moment,so I will have to write it back in before I post the code. Couldn't I use the Connection and DataAdapter objects within .NET for this?

Kris
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:#t*************@TK2MSFTNGP12.phx.gbl...
Can we have the db connection code as well?

By the way, only call the DataBind method on the first page call (ViewState
will take care of keeping the dropdown list populated after that. So,

your
page_load code should be:

Sub Page_Load
If Not IsPostBack Then
cbACType.DataBind()
End If
End Sub
"Kris Rockwell" <kr***************************@hybrid-learning.com> wrote in
message news:un**************@TK2MSFTNGP10.phx.gbl...
Here is the code:

Sub Page_Load
cbACType.DataBind()
End Sub

The database connection information is in my CodeBehind vb file.

Regards,
Kris
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:#Y**************@TK2MSFTNGP12.phx.gbl...
> You can't call the DataBind method (or any method of any object for that > matter) via the design-time property box. It must be called from code. The
> fact that the box drops down with noting in it is what all drop down

boxes
> that don't have data in them do.
>
> Let's see your entire Page_Load event handler.
>
>
> "Kris Rockwell" <kr***************************@hybrid-learning.com>

wrote
in
> message news:eD**************@TK2MSFTNGP12.phx.gbl...
> > I haven't explicitly called it in the code, but I have set it in the > > Property page of the DropDown Box.
> >
> > I did try it though and still got no results. It is strange,
though...The
> > box seems populated in that I can drop it down, but there is no

content
as
> > there should be.
> >
> > Kris
> >
> >
> > "Scott M." <s-***@BADSPAMsnet.net> wrote in message
> > news:#K**************@TK2MSFTNGP09.phx.gbl...
> > > Did you call the .DataBind method of the DropDown box?
> > >
> > >
> > > "Kris Rockwell" <kr***************************@hybrid-learning.com> > wrote
> > in
> > > message news:Od**************@TK2MSFTNGP09.phx.gbl...
> > > > Hello,
> > > >
> > > > I have done the following to bind data to a DropDown box:
> > > >
> > > > 1. Drag SQLServer table onto web form to create data

connection and
> data
> > > > adapter.
> > > >
> > > > 2. Generate dataset by right-clicking on the data adapter ad
selecting
> > > > generate dataset.
> > > >
> > > > 3. Setting the drop down box propertied to reflect so that:
> > > >
> > > > Datasource = Dataset11
> > > > Datamember = table
> > > > Datatextfield = tablerow
> > > > Datavaluefield = tablerow
> > > >
> > > > When I run the application I don't generate any errors, but no

data
is
> > > > present in the DropDown box...Well, actually I get a drop down

that
is
> > > > blank.
> > > >
> > > > Any ideas an what Imay be doing wrong?
> > > >
> > > > Also, if I code the information, can I put it in the
CodeBehind file
> or
> > > does
> > > > it have to be in the actual ASPX?
> > > >
> > > > Thanks in advance,
> > > > Kris
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 18 '05 #10
OK...I got it.

I created a SQLConnection, DataAdapter and Dataset. In the Page load I had
to call the DataBin() and fill the dataset. That was the problem, the
Dataset wasn't being filled.

Thanks for all of your help.

Regards,
Kris
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:OR**************@TK2MSFTNGP12.phx.gbl...
Kris,

All of your compiled code goes in the code-behind. That is what it is there for. Even if you use the Visual DataAdapter and Connection controls, you
are still working with code in the code-behind. When you use those
controls, code is written for you in the code-behind, instead of you
declaring and configuring the classes yourself.

Regardless of whether or not you use the controls or write the code
yourself, we need to see your code in order to help you solve your problem.
Since all it really takes to get the DropDownList control working is to set its DataSource and DataField properties and then to call its DataBind method on the first page call (and you seem to have done that), we can assume that:
either your database connection is not setup correctly or
you are connecting to the db, but not retuning any data

We won't know until you provide us with everything you have.
"Kris Rockwell" <kr***************************@hybrid-learning.com> wrote in message news:uG*************@TK2MSFTNGP09.phx.gbl...
Well, I have kep the DB connection in the code behind page in an effort to
keep it seperate (and thus away from the eyes of curious users) from the
ASPX. In testing different methods I have deleted from the VB code at the moment,so I will have to write it back in before I post the code. Couldn't
I
use the Connection and DataAdapter objects within .NET for this?

Kris
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:#t*************@TK2MSFTNGP12.phx.gbl...
Can we have the db connection code as well?

By the way, only call the DataBind method on the first page call

(ViewState
will take care of keeping the dropdown list populated after that. So,

your
page_load code should be:

Sub Page_Load
If Not IsPostBack Then
cbACType.DataBind()
End If
End Sub
"Kris Rockwell" <kr***************************@hybrid-learning.com>

wrote
in
message news:un**************@TK2MSFTNGP10.phx.gbl...
> Here is the code:
>
> Sub Page_Load
> cbACType.DataBind()
> End Sub
>
> The database connection information is in my CodeBehind vb file.
>
> Regards,
> Kris
> "Scott M." <s-***@BADSPAMsnet.net> wrote in message
> news:#Y**************@TK2MSFTNGP12.phx.gbl...
> > You can't call the DataBind method (or any method of any object for that
> > matter) via the design-time property box. It must be called from

code.
> The
> > fact that the box drops down with noting in it is what all drop

down boxes
> > that don't have data in them do.
> >
> > Let's see your entire Page_Load event handler.
> >
> >
> > "Kris Rockwell" <kr***************************@hybrid-learning.com> wrote
> in
> > message news:eD**************@TK2MSFTNGP12.phx.gbl...
> > > I haven't explicitly called it in the code, but I have set it in

the > > > Property page of the DropDown Box.
> > >
> > > I did try it though and still got no results. It is strange,
> though...The
> > > box seems populated in that I can drop it down, but there is no
content
> as
> > > there should be.
> > >
> > > Kris
> > >
> > >
> > > "Scott M." <s-***@BADSPAMsnet.net> wrote in message
> > > news:#K**************@TK2MSFTNGP09.phx.gbl...
> > > > Did you call the .DataBind method of the DropDown box?
> > > >
> > > >
> > > > "Kris Rockwell"

<kr***************************@hybrid-learning.com>
> > wrote
> > > in
> > > > message news:Od**************@TK2MSFTNGP09.phx.gbl...
> > > > > Hello,
> > > > >
> > > > > I have done the following to bind data to a DropDown box:
> > > > >
> > > > > 1. Drag SQLServer table onto web form to create data connection and
> > data
> > > > > adapter.
> > > > >
> > > > > 2. Generate dataset by right-clicking on the data adapter ad
> selecting
> > > > > generate dataset.
> > > > >
> > > > > 3. Setting the drop down box propertied to reflect so that:
> > > > >
> > > > > Datasource = Dataset11
> > > > > Datamember = table
> > > > > Datatextfield = tablerow
> > > > > Datavaluefield = tablerow
> > > > >
> > > > > When I run the application I don't generate any errors, but no data
> is
> > > > > present in the DropDown box...Well, actually I get a drop down that
> is
> > > > > blank.
> > > > >
> > > > > Any ideas an what Imay be doing wrong?
> > > > >
> > > > > Also, if I code the information, can I put it in the CodeBehind file
> > or
> > > > does
> > > > > it have to be in the actual ASPX?
> > > > >
> > > > > Thanks in advance,
> > > > > Kris
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 18 '05 #11
OK...I got it.

I created a SQLConnection, DataAdapter and Dataset. In the Page load I had
to call the DataBin() and fill the dataset. That was the problem, the
Dataset wasn't being filled.

Thanks for all of your help.

Regards,
Kris
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:OR**************@TK2MSFTNGP12.phx.gbl...
Kris,

All of your compiled code goes in the code-behind. That is what it is there for. Even if you use the Visual DataAdapter and Connection controls, you
are still working with code in the code-behind. When you use those
controls, code is written for you in the code-behind, instead of you
declaring and configuring the classes yourself.

Regardless of whether or not you use the controls or write the code
yourself, we need to see your code in order to help you solve your problem.
Since all it really takes to get the DropDownList control working is to set its DataSource and DataField properties and then to call its DataBind method on the first page call (and you seem to have done that), we can assume that:
either your database connection is not setup correctly or
you are connecting to the db, but not retuning any data

We won't know until you provide us with everything you have.
"Kris Rockwell" <kr***************************@hybrid-learning.com> wrote in message news:uG*************@TK2MSFTNGP09.phx.gbl...
Well, I have kep the DB connection in the code behind page in an effort to
keep it seperate (and thus away from the eyes of curious users) from the
ASPX. In testing different methods I have deleted from the VB code at the moment,so I will have to write it back in before I post the code. Couldn't
I
use the Connection and DataAdapter objects within .NET for this?

Kris
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:#t*************@TK2MSFTNGP12.phx.gbl...
Can we have the db connection code as well?

By the way, only call the DataBind method on the first page call

(ViewState
will take care of keeping the dropdown list populated after that. So,

your
page_load code should be:

Sub Page_Load
If Not IsPostBack Then
cbACType.DataBind()
End If
End Sub
"Kris Rockwell" <kr***************************@hybrid-learning.com>

wrote
in
message news:un**************@TK2MSFTNGP10.phx.gbl...
> Here is the code:
>
> Sub Page_Load
> cbACType.DataBind()
> End Sub
>
> The database connection information is in my CodeBehind vb file.
>
> Regards,
> Kris
> "Scott M." <s-***@BADSPAMsnet.net> wrote in message
> news:#Y**************@TK2MSFTNGP12.phx.gbl...
> > You can't call the DataBind method (or any method of any object for that
> > matter) via the design-time property box. It must be called from

code.
> The
> > fact that the box drops down with noting in it is what all drop

down boxes
> > that don't have data in them do.
> >
> > Let's see your entire Page_Load event handler.
> >
> >
> > "Kris Rockwell" <kr***************************@hybrid-learning.com> wrote
> in
> > message news:eD**************@TK2MSFTNGP12.phx.gbl...
> > > I haven't explicitly called it in the code, but I have set it in

the > > > Property page of the DropDown Box.
> > >
> > > I did try it though and still got no results. It is strange,
> though...The
> > > box seems populated in that I can drop it down, but there is no
content
> as
> > > there should be.
> > >
> > > Kris
> > >
> > >
> > > "Scott M." <s-***@BADSPAMsnet.net> wrote in message
> > > news:#K**************@TK2MSFTNGP09.phx.gbl...
> > > > Did you call the .DataBind method of the DropDown box?
> > > >
> > > >
> > > > "Kris Rockwell"

<kr***************************@hybrid-learning.com>
> > wrote
> > > in
> > > > message news:Od**************@TK2MSFTNGP09.phx.gbl...
> > > > > Hello,
> > > > >
> > > > > I have done the following to bind data to a DropDown box:
> > > > >
> > > > > 1. Drag SQLServer table onto web form to create data connection and
> > data
> > > > > adapter.
> > > > >
> > > > > 2. Generate dataset by right-clicking on the data adapter ad
> selecting
> > > > > generate dataset.
> > > > >
> > > > > 3. Setting the drop down box propertied to reflect so that:
> > > > >
> > > > > Datasource = Dataset11
> > > > > Datamember = table
> > > > > Datatextfield = tablerow
> > > > > Datavaluefield = tablerow
> > > > >
> > > > > When I run the application I don't generate any errors, but no data
> is
> > > > > present in the DropDown box...Well, actually I get a drop down that
> is
> > > > > blank.
> > > > >
> > > > > Any ideas an what Imay be doing wrong?
> > > > >
> > > > > Also, if I code the information, can I put it in the CodeBehind file
> > or
> > > > does
> > > > > it have to be in the actual ASPX?
> > > > >
> > > > > Thanks in advance,
> > > > > Kris
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 18 '05 #12

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

Similar topics

8
by: Kris Rockwell | last post by:
Hello, I have done the following to bind data to a DropDown box: 1. Drag SQLServer table onto web form to create data connection and data adapter. 2. Generate dataset by right-clicking on...
3
by: John Blair | last post by:
Hi, I want to select an id column and a name column from the database and have the results databound to a SINGLE dropdown control with the value property matched to the database id column and...
13
by: Michael Maes | last post by:
Hi, I have a UserControl containing some controls of which one is a ComboBox. All the InternalControls are Private and some are allowed to be accessed through Public Methods. One of the things I...
0
by: Kevin Hodgson | last post by:
I have a ComboBox and a TextBox bound to a Dataset/datatable returned from a SQL Database. The databinding is set in Design Mode. Everything works fine on my initial fill, and I get the correct...
6
by: tfsmag | last post by:
I have a Grid that I've set up to have two of the fields use dropdownlists while in edit mode. Now I can bind the data to the dropdownlists just fine. My problem is that the second dropdown depends...
2
by: hwiechers | last post by:
I have two drop down lists on a page. Each one is hooked up to a separate SqlDataSource. The second data source has a ControlParameter set to the selected value of the first drop down. When I set...
1
by: Rex the Strange | last post by:
I'm having a problem here and am looking for the answer. I have two listboxes. One is a dropdown and the other is a simple list of items which is databound . I want to be able to allow the user to...
0
by: Chris | last post by:
I am using databinding on a pair of cascading dropdowns. You select a team and get the office they can work in. When I try to rebind the second office dropdown I get the following error. ...
2
by: phpmel | last post by:
hi guys, I am using Visual Studio 2005. I have a dropdown list that has an associated SQLdatasource. I also have a textbox below the dropdown list that allows you to add items to the table that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.