hi Friends,
i am having 4 dropdownlists in my web page...when i select first one releated data is foing to be displayed in second dropdown list... and i select 3rd dropdownlist releated data will be display in dropdownlist4....how to do this ....please help me
Loading

Krishna GaradRank #191 · 12.8K reputationPosted Feb 12, 2012, 8:31 PM EST
Satyapriya NayakRank #47 · 31.5K reputationPosted Feb 12, 2012, 8:43 PM EST
Try this...
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Dropdownlist4._Default" %>
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;
using System.Data.SqlClient;
namespace Dropdownlist4
{
public partial class _Default : System.Web.UI.Page
{
string strConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
string str;
SqlCommand com;
protected void Page_Load(object sender, EventArgs e)
{
DropDownList1.AutoPostBack = true;
SqlConnection con = new SqlConnection(strConnString);
if (!IsPostBack)
{
DropDownList1.Items.Add("Choose id");
con.Open();
str = "select * from test";
com = new SqlCommand(str, con);
SqlDataReader reader = com.ExecuteReader();
while (reader.Read())
{
DropDownList1.Items.Add(reader["id"].ToString());
}
reader.Close();
con.Close();
}
DropDownList2.Items.Clear();
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList1.AutoPostBack = true;
SqlConnection con = new SqlConnection(strConnString);
con.Open();
str = "select * from test where id='" + DropDownList1.SelectedItem.Text + "'";
com = new SqlCommand(str, con);
SqlDataReader reader = com.ExecuteReader();
while (reader.Read())
{
DropDownList2.Items.Add(reader["name"].ToString());
}
reader.Close();
con.Close();
}
}
}
Thanks
khaleel shaik11 reputationPosted Feb 12, 2012, 8:50 PM EST
Suthish NairRank #92 · 22.8K reputationPosted Feb 12, 2012, 9:57 PM EST
srikanthreddy27 reputationPosted Feb 13, 2012, 12:10 AM EST
i have problem with dropdownlist 3 and dropdownlist 4....can u please tell me how to solve this problem...........