Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old March 5th, 2006, 09:30 AM
Authorized User
 
Join Date: Feb 2006
Location: , , .
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default How can i change the textbox into a dropdownlist

 Hi guys:

i was trying to change the text box in the Edit template in the form control to a dropdown list. However, when i tried to press the Edit Button to test it, an error page came with a message saying:


Server Error in '/ECBS' Application.
--------------------------------------------------------------------------------

'DepaNameTextBox' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.


what i did is the following change from text box to dropdown list:

DepaName:

<asp:dropdownlist ID="DepaNameTextBox" runat="server" text='<%# Bind("DepaName") %>' Width="137px"></asp:dropdownlist><br />

as you can see the dropdownlist is binded to 'depaName' column. so my next question is, how can i let the dropdown list display the name of the record that was first inserted when i press the edit button to edit that record.

many thanks to any helper


  #2 (permalink)  
Old March 5th, 2006, 04:20 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

You cannot convert a textbox into a dropdownlist. You need to add a dropdownlist to the template. Then on the RowDataBound event get a reference to the textbox and a reference to the dropdownlist. Then you can do a findbytext to set the ddl.

Jim



Similar Threads
Thread Thread Starter Forum Replies Last Post
Dropdownlist index change event problem. thanigaimani83 ASP.NET 1.x and 2.0 Application Design 0 November 7th, 2007 06:40 AM
dropdownlist change jeh3404 ASP.NET 2.0 Basics 1 July 18th, 2007 10:14 PM
adding dropdownlist item to a textbox alto ASP.NET 2.0 Basics 2 May 24th, 2007 01:14 AM
about dropdownlist selected change event chandra_yvr ASP.NET 2.0 Basics 0 April 2nd, 2007 07:20 AM
Newbie HELLLPPPP.... Textbox and DropdownList sane79 ASP.NET 1.0 and 1.1 Basics 3 October 3rd, 2005 12:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.