473,597 Members | 2,342 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 insertItemTempl ate and editItemTemplat e. 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 2331
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********@hot mail.comwrote in message
news:11******** **************@ n67g2000cwd.goo glegroups.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 insertItemTempl ate and editItemTemplat e. 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 objectdatasourc e 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
6032
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 "LabLocation_ID". With an existing lab, they then need to add the members for that lab. So, what I am trying to do is the following. With the FormView of the Lab open, the user will click a button to open a FormView (InsertMode) and add a new...
0
1381
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 formview Init or ItemCreated event: Dim cbo As DropDownList = CType(Me.fmViewUser.Row.Cells(0).FindControl("ddNameInsert"), DropDownList) or
2
7894
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 FormView's ObjectDataSource "odsRegistrant" . The following solution can't work because I need the ddl selected value bound to my odsRegistrant but both tables have the same column name for primary key. <asp:DropDownList ID="ddlOfficePark"...
1
2364
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 uploaded file only being displayed in the second list. I would like to avoid the dropdown being filled twice but my knowledge is still pretty limited so I would be gratefull for help. Also if someone could perhaps point me to how I make the just...
0
1032
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 fine when ratedatasource finds a row, but when it doesnot my dropdowns dont get popultated. Keep in mind I have two datasources, one for the form the other for my dropdownlist.
0
1185
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" ContentPlaceHolderID="PageContentPlaceHolder" runat="Server"> <asp:AccessDataSource id="DataSource1" Runat="Server"
0
5934
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 in the FormView ItemTemplate Nested Gridview ddlName ItemTemplate. My label is named lgvTimeKeep and the dropdownlist name is ddlName. Thanks!
1
1519
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 not empty. when i click on the insert Link the data should be displayed in the gridView (Which is below the formview), But when i click on the Insert link the data is displayed in the gridView, But the DropdownList is empty. Here is the...
0
1210
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 not empty. when i click on the insert Link the data should be displayed in the gridView (Which is below the formview), But when i click on the Insert link the data is displayed in the gridView, But the DropdownList is empty.
0
7886
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8381
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8035
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8258
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6688
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5431
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3927
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2404
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1238
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.