asp.net 怎么在内容页面初始化的时候获得该内容页面中用户控件中DropDownList选定的值
asp.net 如何在内容页面初始化的时候获得该内容页面中用户控件中DropDownList选定的值
public partial class Company : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Bind();
}
}
public void Bind()
{
ClassCom c = new ClassCom();
List<ClassCom> ClassComItems = new List<ClassCom>()
{
new ClassCom{CID=1,CName="小一"},
new ClassCom{CID=2,CName="小二"},
new ClassCom{CID=3,CName="小三"},
new ClassCom{CID=4,CName="小四"}
};
this.DropDownList_Company.DataSource = ClassComItems;
this.DropDownList_Company.DataTextField = "CName";
this.DropDownList_Company.DataValueField = "CID";
this.DropDownList_Company.DataBind();
this.SelectValue = this.DropDownList_Company.SelectedValue;
}
[Category("数据绑定")]
private string _SelectValue;
public string SelectValue
{
get { return _SelectValue; }
set { _SelectValue = value; }
}
}
public partial class Company : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Bind();
}
}
public void Bind()
{
ClassCom c = new ClassCom();
List<ClassCom> ClassComItems = new List<ClassCom>()
{
new ClassCom{CID=1,CName="小一"},
new ClassCom{CID=2,CName="小二"},
new ClassCom{CID=3,CName="小三"},
new ClassCom{CID=4,CName="小四"}
};
this.DropDownList_Company.DataSource = ClassComItems;
this.DropDownList_Company.DataTextField = "CName";
this.DropDownList_Company.DataValueField = "CID";
this.DropDownList_Company.DataBind();
this.SelectValue = this.DropDownList_Company.SelectedValue;
}
[Category("数据绑定")]
private string _SelectValue;
public string SelectValue
{
get { return _SelectValue; }
set { _SelectValue = value; }
}
}
ASP.NET
DropDownList
控件
- 1net 调用oracle存储过程(PLS-00306),该怎么解决
- 2如何将部门和子部门在一个listbox中显示
- 3ajax异步登陆页面无法跳转解决办法
- 4大三在校生的传智120天的1200小时.net(十三)关于Response.Redirect跟Server.Execute的区别
- 5web api怎么显示序列化datatable
- 6Dapper小型ORM的使用(任意吐槽下公司)
- 7替年度评选活动添加倒计时功能
- 8asp.net word操作有关问题
- 9小弟我有一共享打开数据库类,第一次打开时没有异常,以后打开就出现异常,请教高手怎样纠正,多谢
- 10项目中摘引CodeSmith相关的DLL
- 上一篇:.Net的生命力依然鼎盛
- 下一篇:这么的dll可以调用吗
文章评论
相关解决方案