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:
Sahu

Employee Code:

Employee Type:


Rate:;

Work Hours:


Total:;

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


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()"); }

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.

document.getElementById('<%=ddltype.ClientID%>').value;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.