TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
selvi subramanian
NA
799
574.8k
Dropdowm did not show the value of next one
Apr 19 2012 4:01 AM
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="list.aspx.cs" Inherits="list" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.style1
{
width: 100%;
}
.style2
{
width: 412px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="style1">
<tr>
<td class="style2">
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
</td>
<td>
</td>
</tr>
<tr>
<td class="style2">
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True"
onselectedindexchanged="DropDownList2_SelectedIndexChanged">
</asp:DropDownList>
</td>
<td>
</td>
</tr>
<tr>
<td class="style2">
<asp:DropDownList ID="DropDownList3" runat="server" AutoPostBack="True">
</asp:DropDownList>
</td>
<td>
</td>
</tr>
<tr>
<td class="style2">
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
</td>
<td>
</td>
</tr>
<tr>
<td class="style2">
</td>
<td>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Coding
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class list : System.Web.UI.Page
{
Class1 cls = new Class1();
DataSet ds = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
sel();
}
}
private void sel()
{
DataSet ds = new DataSet();
ds = cls.getds("select State,StateId from State");
ListItem li = new ListItem();
li.Value = "0";
li.Text = "-Select-";
DropDownList1.Items.Add(li.ToString());
foreach (DataRow dr in ds.Tables[0].Rows)
{
ListItem li1 = new ListItem();
li1.Text = dr["State"].ToString();
DropDownList1.Items.Add(li1.ToString());
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList2.Items.Clear();
DataSet ds = new DataSet();
ds = cls.getds("select City,CityId from City where StateId='" + DropDownList1.SelectedIndex.ToString() + "'");
ListItem li3 = new ListItem();
li3.Value = "0";
DropDownList2.Items.Add(li3.ToString());
foreach (DataRow dr in ds.Tables[0].Rows)
{
ListItem li2 = new ListItem();
li2.Value = dr["CityId"].ToString();
li2.Text = dr["City"].ToString();
DropDownList2.Items.Add(li2.ToString());
}
}
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList3.Items.Clear();
DataSet ds = new DataSet();
ds = cls.getds("select Location,LocationId from Location where CityId='" + DropDownList2.SelectedIndex.ToString() + "'");
ListItem li7 = new ListItem();
li7.Text = "-select";
li7.Value = "0";
DropDownList3.Items.Add(li7.ToString());
foreach (DataRow dr in ds.Tables[0].Rows)
{
ListItem li8 = new ListItem();
li8.Value = dr["LocationId "].ToString();
li8.Text = dr["Location"].ToString();
DropDownList3.Items.Add(li8.ToString());
}
}
}
Reply
Answers (
12
)
Checkbox checked event in repeator
Session