Click here to Skip to main content
14,922,560 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I want to display the Department values, I'm using only one dropdownlist.Please any one help to me.

<asp:DropDownList ID="dropdown1" runat="server" AutoPostBack="true">
                <asp:ListItem Text="CSC" Value="CSC"></asp:ListItem>
                <asp:ListItem Text="ECE" Value="ECE"></asp:ListItem>
                <asp:ListItem Text="EEE" Value="EEE"></asp:ListItem>
                <asp:ListItem Text="MECH" Value="MECH"></asp:ListItem>
                <asp:ListItem Text="Other" Value="Other"></asp:ListItem>

                    <asp:TextBox ID="txtDept" runat="server"></asp:TextBox>


1 solution

Your solution is very simple given below if it is not your solution then ask again


 <%@ Page Title="Home Page" Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false"
    CodeBehind="Default.aspx.vb" Inherits="WebApplication4VB._Default" %>

<asp:content id="HeaderContent" runat="server" contentplaceholderid="HeadContent" xmlns:asp="#unknown">
<asp:content id="BodyContent" runat="server" contentplaceholderid="MainContent" xmlns:asp="#unknown">
<asp:dropdownlist id="dropdown1" runat="server" autopostback="true" onselectedindexchanged="dropdown1_SelectedIndexChanged">
                <asp:listitem text="CSC" value="CSC"></asp:listitem>
                <asp:listitem text="ECE" value="ECE"></asp:listitem>
                <asp:listitem text="EEE" value="EEE"></asp:listitem>
                <asp:listitem text="MECH" value="MECH"></asp:listitem>
                <asp:listitem text="Other" value="Other"></asp:listitem>
     Name of the Department: <asp:textbox id="txtDept" runat="server"></asp:textbox>


In Code behind .vb

Public Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub dropdown1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dropdown1.SelectedIndexChanged
        txtDept.Text = dropdown1.SelectedValue.ToString()
    End Sub

End Class
Member 11398751 27-Jan-15 2:09am

Thank You for Your Help.

I tried this, but i got the error:

Parser Error Message: Content controls have to be top-level controls in a content page or a nested master page that references a master page.

Anisuzzaman Sumon 27-Jan-15 2:31am
Have you a master page named Site.Master? and have you just copied and pasted is aspx there was some garbase like CDDATA[ etc check now

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900