Search:
Namespaces
Discussions
.NET v1.1
Feedback
Newbie databind dropdownlist question
Messages
Related Types
This message was discovered on
microsoft.public.dotnet.framework.aspnet.webcontrols
.
Post a new message to this list...
dw
Hello, all. I'm just starting to work with ASP.NET in VS.NET 2003. I've
created a page with a dropdownlist server control (lstStates) that should
pull in the contents of an Access table tblValidStateAbbr (has states and
their abbreviations). However, no matter what I do, I can't get the dropdown
to show any data on the page.
I have a connection, an OLE DB data adapter, and a dataset that contains the
SELECT to the tblValidStateAbbr. All were created via double-clicking the
data objects on the DATA tab of the Toolbox and following the wizards.
In the pageload event of the code behind file, I have this code. I've been
doing years of ASP development, and ASP.NET is new to me. I think I'm
missing something simple. Any help is appreciated. Thank you.
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.Load
Me.OleDbDataAdapter1.Fill(Me.DsStates1)
Me.lstStates.DataBind()
End Sub
Reply to this message...
Scott M.
Where is the drop down setting its data source?
"dw" <
Click here to reveal e-mail address
> wrote in message
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
dw
Scott, I got it! I had set the Data Member property for the drop down in the
Property window to tblValidStateAbbr. Once I cleared that, it worked.
Apparently you can't have both the Data Source and Data Member with values
in them. Thanks for your help.
"Scott M." <
Click here to reveal e-mail address
> wrote in message
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
dw
Scott, I've got another question: How do I use the same data adapter to pull
in another table unrelated to the states table? Thanks.
"dw" <
Click here to reveal e-mail address
> wrote in message
news:epQv%
Click here to reveal e-mail address
...
> Scott, I got it! I had set the Data Member property for the drop down in
the
[Original message clipped]
Reply to this message...
Scott M.
A
DataAdapter
works based on its Command Objects (Select, Insert, Update &
Delete) that are child objects of the
DataAdapter
object. If you want to
pull data from a different table in, you'll either have to change the Select
Command of the
DataAdapter
to a new SQL statement (or stored procedure) and
re-fill your
DataSet
or use a new
DataAdapter
.
"dw" <
Click here to reveal e-mail address
> wrote in message
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
Scott M.
I have found that it is not a good idea to set the DataSource, DataTextField
or DataMember properties using the properties window because they do cause
problems when you want to do something later in code that requires a
different setting for these, so if I am going to create the object using
design techniques, I set these values in code.
"dw" <
Click here to reveal e-mail address
> wrote in message
news:epQv%
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
dw
Thank you, Scott :) Very good information. I appreciate your time on this.
"Scott M." <
Click here to reveal e-mail address
> wrote in message
news:
Click here to reveal e-mail address
...
> I have found that it is not a good idea to set the DataSource,
DataTextField
[Original message clipped]
Reply to this message...
Scott M.
No problem. Good luck!
"dw" <
Click here to reveal e-mail address
> wrote in message
news:%
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
dw
Thanks, Scott, for your reply. I set the Data Source of the drop down by
selecting it in Design View and going to the the Property window, and simply
selecting the dsStates1 dataset. That's also where I set the DataTextField
and DataValueField to "state" and "abbr" (without the quotations).
"Scott M." <
Click here to reveal e-mail address
> wrote in message
news:
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
System.Data.Common.DataAdapter
System.Data.DataSet
System.EventArgs
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com