473,381 Members | 1,419 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,381 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 2313
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: sck10 | last post by:
Hello, I am creating a form for users to enter information about a lab and the members of the lab. I have one form (FormView) that they use to enter information about that lab. The keyvalue is...
0
by: Rabbit | last post by:
Hi, All, I have a FormView, in which the InsertItemTemplate has a dropdownlist that I need to set the datasource as my self created dataset. I have been trying various syntax like following at...
2
by: Dabbler | last post by:
In my Registrant FormView I have a DropDownList which loads data from a secondary SqlDataSource "sdsOfficeParks". I need the user to select an office park but save the selected value in the...
1
by: Bob | last post by:
I've made an upload function saving to a specific folder and dropdownlist reading and listing files from the folder. When I upload, the list is rendered a second time in the dropdownlist with the...
0
by: jobs at webdos | last post by:
My challenge is I need to populate a formview's dropdownlist even when my datasource does not find a record to bind with. I'm trying to avoid binding in the codebehind. This code works works...
0
by: Jon Paal | last post by:
--dropdownlist value isn't being saved to database from FORMVIEW --field PriorityID is datatype "number" (integer) what's missing ???? '=========code============= <asp:Content ID="Content1"...
0
by: sgtmarcjones | last post by:
How do I access a dropdownlist that is nested within a Formview ItemTemplate Gridview Template? I want to see a label (lgbTimeKeep ! TextValue of ddlName dropdownlist) instead of a dropdownlist...
1
by: Anilsg | last post by:
Hi all, I have the DropDownList in the FormView,inside InsertTemplateField The data is binded in run time to it in codebehind page,FOr the First time the page is loaded the DropdownList is...
0
by: Anilsg | last post by:
Hi all, I have the DropDownList in the FormView,inside InsertTemplateField The data is binded in run time to it in codebehind page,FOr the First time the page is loaded the DropdownList...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.