0% found this document useful (0 votes)
6 views

dropdownlistbox

Uploaded by

pshiv09098
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

dropdownlistbox

Uploaded by

pshiv09098
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

DropDownListBox Demo

Design View

Source Code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="dropdownlistboxdemo.aspx.cs"
Inherits="unit1programs.dropdownlistboxdemo" %>

<!DOCTYPE html>

<html xmlns="h p://www.w3.org/1999/xhtml">


<head runat="server">
< tle></ tle>
<style>
body
{
background-image:url("images/holi.jpg");
background-size:cover;
}
#form1
{
height: 600px;
width: 500px;
background-color:aquamarine;
margin-le :auto;
margin-right:auto;
opacity:0.9;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="auto-style3">
<tr>
<td colspan="2" class="auto-style4" style="font-family: Arial; font-size: medium; font-weight:
bold">Addres Informa on</td>
</tr>
<tr>
<td class="auto-style5">
<asp:Label ID="Label1" runat="server" Text="City"></asp:Label>
</td>
<td class="auto-style1">
<asp:DropDownList ID="ddlcity" runat="server" Height="19px" Width="163px"
AutoPostBack="True" OnSelectedIndexChanged="ddlcity_SelectedIndexChanged">
<asp:ListItem>Kolhapur</asp:ListItem>
<asp:ListItem>Sangali</asp:ListItem>
<asp:ListItem>Satara</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="Taluka"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ddltaluka" runat="server" Height="19px" Width="163px"
AutoPostBack="True"
OnSelectedIndexChanged="ddltaluka_SelectedIndexChanged"></asp:DropDownList>

</td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text="Village"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlvillage" runat="server" Height="19px"
Width="163px"></asp:DropDownList>

</td>
</tr>
<tr>
<td colspan="2" >
<asp:Bu on ID="btnsubmit" runat="server" Text="Submit" OnClick="btnsubmit_Click" />

</td>
</tr>
<tr>
<td colspan="2">
<asp:ListBox ID="lstdisplay" runat="server" Height="80px" Width="317px"></asp:ListBox>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>

Code -
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (ddlcity.Text == "Kolhapur")
{
ddltaluka.Items.Add("Kagal");
ddltaluka.Items.Add("Radhanagari");
ddltaluka.Items.Add("Budhargard");
}
if (ddlcity.Text == "Sangali")
{
ddltaluka.Items.Add("Miraj");
ddltaluka.Items.Add("Tasgaon");
ddltaluka.Items.Add(".....");
}
if (ddlcity.Text == "Satara")
{
ddltaluka.Items.Add("Karad");
ddltaluka.Items.Add("Maan");
ddltaluka.Items.Add("Budhargard");
}
}
}

protected void ddlcity_SelectedIndexChanged(object sender, EventArgs e)


{
ddltaluka.Items.Clear();
if (ddlcity.Text == "Kolhapur")
{
ddltaluka.Items.Add("Kagal");
ddltaluka.Items.Add("Radhanagari");
ddltaluka.Items.Add("Budhargard");
}
if (ddlcity.Text == "Sangali")
{
ddltaluka.Items.Add("Miraj");
ddltaluka.Items.Add("Tasgaon");
ddltaluka.Items.Add(".....");
}
if (ddlcity.Text == "Satara")
{
ddltaluka.Items.Add("Karad");
ddltaluka.Items.Add("Maan");
ddltaluka.Items.Add("Budhargard");
}

protected void ddltaluka_SelectedIndexChanged(object sender, EventArgs e)


{
ddlvillage.Items.Clear();
if(ddltaluka.Text== "Kagal")
{
ddlvillage.Items.Add("Bidri");
ddlvillage.Items.Add("Borawade");
ddlvillage.Items.Add("Sonali");
}
if (ddltaluka.Text == "Radhanagari")
{
ddlvillage.Items.Add("Titave");
ddlvillage.Items.Add("Turambe");
ddlvillage.Items.Add("Walava");
}
if (ddltaluka.Text == "Budhargard")
{
ddlvillage.Items.Add("Mudal");
ddlvillage.Items.Add("Koor");
ddlvillage.Items.Add("Adamapur");
}
if (ddltaluka.Text == "Miraj")
{
ddlvillage.Items.Add("Sangali");
ddlvillage.Items.Add("Peth");
ddlvillage.Items.Add("Kavathe");
}
}

protected void btnsubmit_Click(object sender, EventArgs e)


{
lstdisplay.Items.Add("Address Informa on");
lstdisplay.Items.Add("City : " + ddlcity.Text);
lstdisplay.Items.Add("Taluka : " + ddltaluka.Text);
lstdisplay.Items.Add("Village: " + ddlvillage.Text);
}

You might also like