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
Pandurang Chavan
NA
1
0
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
Reply
Answers (
0
)
How to apply css to content page
File Attachments?