绑定下拉列表和详细信息视图 [英] Binding Dropdown list and Detail view

查看:90
本文介绍了绑定下拉列表和详细信息视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个下拉列表,用于显示公司名称,以及一个详细信息"视图以在一个网页中显示公司的其他详细信息.
我已经将数据加载到了dropdownlist中.
我的要求是必须在下拉列表abc公司详细信息中选择的abc公司名称必须显示在详细信息视图中.

您能给我建议的方法吗?

谢谢.

Hi
I have a Drop down list which display the company name and a Detail view to display other details of the company in one web page.
i already loaded the data in dropdownlist.
My requirement is when the abc company name selected in dropdown list abc companys details has to display in detail view.

Could you please advice how to do?

Thanks.

推荐答案

确保在aspx中将DropDownList的AutoPostBack属性设置为True

make sure you set AutoPostBack Property of DropDownList to True in aspx

<asp:dropdownlist id="ddlCompany" runat="server" onselectedindexchanged="ddlCompany_SelectedIndexChanged" autopostback="true" xmlns:asp="#unknown" />



以下是您背后的代码中的事件处理程序



the below is your event handler in code behind

protected void ddlCompany_SelectedIndexChanged(object sender, EventArgs e)
{
   string strCompID = ddlCompany.SelectedValue.ToString();
   //bind here your DetailView's data bsed on the selected ID strCompID.
}


这篇关于绑定下拉列表和详细信息视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆