471,592 Members | 1,106 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Populating Dropdownlist in Formview

I am trying to do something which seems (to me) to be very simple, and
yet I can't seem to figure it out.

I have a gridview and a formview. When a user clicks "select" in the
gridview, the formview opens. The user can then click "insert" or
"update" to either create a new row or edit the existing row.

This all works fine as long as I only use textboxes and checkboxes in
my insertItemTemplate and editItemTemplate. What I would like to do is
have one field that is bound to a dropdownlist, which is populated when
the user clicks update or insert.

The problems is: I can't figure out how to access the dropdownlist to
get it populated. In all the events I've tried, using FindControl on
the formview yields controls like ChildTable, FormViewRow, etc., but no
dropdownlists.

This has to be a common problem, yet none of my searches yields a
working example.

Thanks for any insight.

Phil

Dec 19 '06 #1
2 2250
You'll need to create a templatefield/column first, then manually put a
dropdownlist there, yourself. The link to the following sample uses a
DetailsView, but the process is the same:
http://aspnet101.com/aspnet101/aspne...x?code=dvddlmd

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com

"Phil Sandler" <ps********@hotmail.comwrote in message
news:11**********************@n67g2000cwd.googlegr oups.com...
I am trying to do something which seems (to me) to be very simple, and
yet I can't seem to figure it out.

I have a gridview and a formview. When a user clicks "select" in the
gridview, the formview opens. The user can then click "insert" or
"update" to either create a new row or edit the existing row.

This all works fine as long as I only use textboxes and checkboxes in
my insertItemTemplate and editItemTemplate. What I would like to do is
have one field that is bound to a dropdownlist, which is populated when
the user clicks update or insert.

The problems is: I can't figure out how to access the dropdownlist to
get it populated. In all the events I've tried, using FindControl on
the formview yields controls like ChildTable, FormViewRow, etc., but no
dropdownlists.

This has to be a common problem, yet none of my searches yields a
working example.

Thanks for any insight.

Phil

Dec 19 '06 #2
David Wier wrote:
You'll need to create a templatefield/column first, then manually put a
dropdownlist there, yourself. The link to the following sample uses a
DetailsView, but the process is the same:
http://aspnet101.com/aspnet101/aspne...x?code=dvddlmd
Thanks for your reply.

This is not exactly what I'm trying to do. I want to find the control
in a formview event and populate it via a custom method that creates a
datatable.

This link looks like it uses an objectdatasource for populating the
DDL.

The main problem I'm having is that I can't seem to use FindControl to
get to the ddl.

Thanks,

Phil

Dec 19 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Bob | last post: by
reply views Thread by jobs at webdos | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.