473,395 Members | 1,568 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,395 software developers and data experts.

Replacing TEXTBOX with DROPDOWNLISTBOX in Formview

I have an existing textbox in a formview edit or insert and I wish to
convert it to a DROPDOWNLIST BOX but I can not figure out the syntax
to create the bind that was in the textbox, to how that should be coded
for the DDL

Can anyone please advise

ORIGINAL

<asp:TextBox ID="GenIDTextBox" runat="server" Text='<%# Bind("GenID")
%>'>
</asp:TextBox>

PROPOSED

<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="AccessDataSourceTest"
DataTextField="GenName" DataValueField="GenID">
</asp:DropDownList>

<asp:AccessDataSource ID="AccessDataSourceTest" runat="server"
DataFile="~/App_Data/TreesAll.mdb"
SelectCommand="SELECT [GenName], [GenID] FROM [Genus] ORDER BY
[GenName]">
</asp:AccessDataSource>

May 22 '06 #1
2 1486
Miracles - never cease.

I think I solved it myself, but any comments or advice would be
appreciated

Solution

Add to the DDL definition the following

SelectedValue='<%# Bind("GenID") %>'

so new DDL is

<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="AccessDataSourceTest"
DataTextField="GenName" DataValueField="GenID"
SelectedValue='<%# Bind("GenID") %>' >
</asp:DropDownList>

Tim

May 22 '06 #2
Correct. The current value is Text for the TextBox and SelectedValue for the
drop down.. Seems to make sense to me...

--
Patrice

"mosscliffe" <pa***********@googlemail.com> a écrit dans le message de news:
11**********************@i40g2000cwc.googlegroups. com...
Miracles - never cease.

I think I solved it myself, but any comments or advice would be
appreciated

Solution

Add to the DDL definition the following

SelectedValue='<%# Bind("GenID") %>'

so new DDL is

<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="AccessDataSourceTest"
DataTextField="GenName" DataValueField="GenID"
SelectedValue='<%# Bind("GenID") %>' >
</asp:DropDownList>

Tim

May 22 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Ottar | last post by:
I have a few numeric fields, and when I update i get the error: "Input string was not in a correct format". Next line:" System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer&...
4
by: Luqman | last post by:
How can I display any field value in textbox of sqldatasource using VS.Net 2005 ? Say : Dim x as new AccessDataSource X.connectionstring="Data source="D:\mydb.mdb" X.Selectcommand="Select...
2
by: Liones | last post by:
Hi, In javascrip i have to find a "Versam20TextBoxEd" in a FormView but i get error of compilation the "Versam20TextBoxEd" is not in the context I can find the FormView...
1
by: Ted | last post by:
Here is a stored procedure I created in MySQL: CREATE PROCEDURE `sp_find_food`( IN search_string varchar(255) ) BEGIN DECLARE ss VARCHAR(257); SET ss = CONCAT('%',search_string,'%'); SELECT...
2
by: J055 | last post by:
Hi The client script does not get created when calling the Focus method on the TextBox. No errors occur. What am I doing wrong please? protected void fv_Load(object sender, EventArgs e) {...
0
by: Paul | last post by:
I have a web form with a FormView that will display data based on an entry in the TextBox. I want to add a second FormView to work with a second TextBox. However, when I add the second TextBox,...
1
by: jeyapriya | last post by:
Dear Friends This is Jeyapriya. Right now I am working in the ASP.NET with VB coding & the back end is SQL SERVER 2000. My dilemma is I have to design a form with 2 DropDownListboxes. I have...
9
by: David C | last post by:
I have an asp.net page that contains a FormView with several controls bound to a SqlDataSource. One of the controls is a TextBox bound to a date column. I have the following additional properties...
0
by: mesut | last post by:
Hi colleagues, I've a very strange problem here. I have no clue whyt it happens. I have a listview. The Listview populates well. I have an Update Button in the listview and a...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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,...

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.