hey i want to change the textbox from the dropdownlist.....whatever item is selected from my dropdownlist i want to display in my textbox......i have used the below code but its not working.

and i also want to autogenerate the code for employee code for eg. if employee first name Aaron and last name is Lobo then, his employee code will be AL i.e first letter of first name and last name.

Please help and correct me if the code is wrong somewhere.........

<%@ Page Language="C#"
AutoEventWireup="true" CodeFile="employeedetail.aspx.cs"
Inherits="employeedetail" %> Untitled Page

First Name:Mantu;

Last Name:

Employee Code:

Employee Type:


Work Hours:


<script language="javascript">
                function ShowValue()
                  document.form1["txtrate"].value  = document.form1["ddltype"].value;

public partial class employeedetail : System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e) { if
(!Page.IsPostBack) { ArrayList items = new
ArrayList(); items.Add("Regular");
items.Add("Non-Regular"); ddltype.DataSource = items;
ddltype.DataBind(); } }
protected void ddltype_SelectedIndexChanged(object sender,
EventArgs e) { ddltype.Attributes.Add("onchange",
"javascript:ShowValue()"); }

Edited by __avd: Added [code] tags.

6 Years
Discussion Span
Last Post by dnanetwork

I think you are mixing two things here, i recommend you or you use javascript or c#, I see you have the selectedIndexChange method so your dropdownlist goes like this.

<asp:DropDownList ID="ddlType" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlType_SelectedIndexChanged" />

Now your page load is fine but within your selectedindexchanged method just do this

txtrate.Text = ddlType.SelectedItem.Value;

if you really need the javascript version let me know.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.