Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - Populating Dropdownlist in Formview

 
Thread Tools Search this Thread
Old 12-19-2006, 03:33 PM   #1
Default 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



Phil Sandler
  Reply With Quote
Old 12-19-2006, 04:00 PM   #2
David Wier
 
Posts: n/a
Default Re: Populating Dropdownlist in Formview
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" <> wrote in message
news: 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
>





David Wier
  Reply With Quote
Old 12-19-2006, 05:54 PM   #3
Phil Sandler
 
Posts: n/a
Default Re: Populating Dropdownlist in Formview
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



Phil Sandler
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom control dropdownlist - need advice tcstom Software 0 04-18-2008 11:28 AM
populating data from sql server to pdf using asp.net gijichacko Software 0 08-10-2007 12:31 PM
dynamic validations for checkboxlist and dropdownlist mrugesh_dulera Software 0 06-26-2007 01:56 AM
DropdownList in gridview visj4u Software 0 04-27-2007 01:11 PM
Formview with ObjectDataSource rturner003 Software 0 10-26-2006 12:26 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46