dropdownlistbox
dropdownlistbox
Design View
Source Code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="dropdownlistboxdemo.aspx.cs"
Inherits="unit1programs.dropdownlistboxdemo" %>
<!DOCTYPE html>
</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");
}
}
}