usercontrl - findbytext selection

Jun 16 2009 8:20 AM
I have created usercontrol with dropdownlist but and I want to select value from other dropdownlist ... pls refer below code.

1.DropDownList1 is my web page dropdownlist
2.webUserControl - web control -in dropdownlsit name section
- when i click on Button1 . DropDownList1 list selected value should find in usercontrol dropdownlist and display (selected)

******************************
Default web form coding
*****************************


public partial class _Default : System.Web.UI.Page
{


protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
kssConnectionstring.kssconnctionclass myobj = new kssConnectionstring.kssconnctionclass();
string xservername = "win2006";
string xdatabase = "School";
DropDownList1.DataSource = myobj.GetStoredProcData(xservername, xdatabase, "RetSection");
DropDownList1.DataTextField = "sectionnm";
DropDownList1.DataBind();
}

}
protected void Button1_Click(object sender, EventArgs e)
{
string selstring;
selstring = DropDownList1.SelectedValue;
WebUserControl dss = new WebUserControl();
dss.mydropdownlist.Items.FindByText("+selstring+").Selected = true;
}

}
****************************
*Usercontrol coding
*****************************

public partial class WebUserControl : System.Web.UI.UserControl
{

public DropDownList mydropdownlist
{

get { return ddlSection ; }
set { ddlSection = value; }
}

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
kssConnectionstring.kssconnctionclass myobj = new kssConnectionstring.kssconnctionclass(); //calling class
string xservername = "win2006";
string xdatabase = "School";
ddlSection.DataSource = myobj.GetStoredProcData(xservername, xdatabase, "RetSection");
ddlSection.DataTextField = "sectionnm";
ddlSection.DataBind();
}

}
}

pls help me ...

Thanks in advnace
Pandurang