Populating Dropdownlist in Formview

  • Thread starter Thread starter Phil Sandler
  • Start date Start date
P

Phil Sandler

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
 
David said:
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/aspnet/codesample.aspx?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
 
Back
Top