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
572.6k
3 dropdown values does not shown in 2 dropdown list
Apr 18 2012 7:26 AM
3 dropdown values does not shown in 2 dropdown list
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 shwdetl : 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 CompanyName,ClientId from Client");
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["ClientId"].ToString();
DropDownList1.Items.Add(li1.ToString());
}
}
protected void Button1_Click(object sender, EventArgs e)
{
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList2.Items.Clear();
DataSet ds = new DataSet();
ds = cls.getds("select ModuleId,ModuleName from Module where ClientId='" + 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["ModuleId"].ToString();
li2.Text = dr["ModuleName"].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 Design,Code from Desgn where ModuleId='" + 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["Design"].ToString();
li8.Text = dr["Code"].ToString();
DropDownList3.Items.Add(li8.ToString());
}
}
}
<!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: 407px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="style1">
<tr>
<td class="style2">
<asp:Label ID="Label2" runat="server" Text="Client"></asp:Label>
</td>
<td>
<asp:DropDownList ID="DropDownList1" runat="server"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style2">
<asp:Label ID="Label3" runat="server" Text="Design"></asp:Label>
</td>
<td>
<asp:DropDownList ID="DropDownList2" runat="server"
onselectedindexchanged="DropDownList2_SelectedIndexChanged">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style2">
<asp:Label ID="Label4" runat="server" Text="Task"></asp:Label>
</td>
<td>
<asp:DropDownList ID="DropDownList3" runat="server">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style2">
<asp:Label ID="Label1" runat="server" Text="Name"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
</td>
<td>
</td>
</tr>
<tr>
<td class="style2">
</td>
<td>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Reply
Answers (
4
)
How to use javascript for a radio button using asp.net c#
Login and Logout time calculation in asp.net using C#