How To? Bind MS Access to DropDownList?

T

troy.forster

I am sure this must be about the simplest thing to do. I can whip
something off in 10 different languages and environments with no
problem. But VisualStudio 2003 and ASP.NET is sooooo frustrating!!!

My example is simple. I have an Access table (mytable) with two fields
of type text (userid and password).

I want to display a dropdownlist on a page and have it list the
userids. Nothing more.

Since VisualStudio is a little more graphical than, say, notepad, I
want to take advantage of drag and drop programming.

I create my database connection in the server panel.
I add an OleDbConnection, OleDbDataAdapter and DataSet (not sure if
this is right but it seemed like I was being lead in that direction).

Next I drop a dropdownlist on the form. Goto properties and set
DataSource = DataSet11
DataMember = mytable
DataTextField = userid
DataValueField = userid

Build and view and I get a nice white page with an empty dropdown list
sitting on it. Tried addind DataBind() to the page_load and still
nothing.

Tried searching help/gotdotnet/msdn/etc and find plenty of examples on
databinding to arraylists and other datasource types but nothing that
helps me out. Some examples I didn't try but they involved 20-30 lines
of code. Surely it doesn't take that much code now, in a drag and drop
IDE, to do what we could do in ASP.Classic and notepad in 4 lines?

Please help, or better yet point me to a resource that so far has
eluded by many Google attempts?

Thanks,

T
 
N

neilmcguigan

add db connection
add data adapter
create dataset from data adapter
set dataset as datasource, and set datatextfield and datavaluefield

switch to Page_Load event handler

call dataadapter.Fill(dataset)
call dropdownlist.DataBind()

cheers
 
F

Frankie

<<I can whip something off in 10 different languages and environments with
no problem>>

You must be amazing! I didn't know there were 10 different languages AND
environments. What are they? Apparently NONE of them are .NET languages or
Visual Studio because that's where you're having trouble. Can you just
provide a simple list of what they are? All 10 of them? Or even 5 of them.
That would be great to know.

(really curious here!)

Thanks!

-F
 
M

Mr Newbie

LOL


Frankie said:
<<I can whip something off in 10 different languages and environments with
no problem>>

You must be amazing! I didn't know there were 10 different languages AND
environments. What are they? Apparently NONE of them are .NET languages or
Visual Studio because that's where you're having trouble. Can you just
provide a simple list of what they are? All 10 of them? Or even 5 of them.
That would be great to know.

(really curious here!)

Thanks!

-F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top