dropdownlist选择的索引改变了吗? [英] dropdownlist selected index changed?
本文介绍了dropdownlist选择的索引改变了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在花药drpdownlist中查看下拉列表的对应值
大家好,
我正在使用一个下拉列表从DB显示EmpNO
我想要当我选择下拉值时,它应该显示对应的值
在另一个下拉列表中.但是不知道如何执行此操作.请告诉我这是什么C#代码.
view dropdownlist corrosponding value in anther drpdownlist
hi all,
i am using one dropdownlist for showing EmpNO from DB
i want when i select dropdown value it should be display corresponing value
in another dropdownlist.but don''t know how to do this.tell me what is c# code for this.
推荐答案
如果您正在讨论级联下拉列表,请检查这些
在级联下拉列表中动态选择值 [ ^ ]
如何使用另一个ddl填充下拉列表 [ ^ ]
层叠下拉菜单-国家/地区 [ ^ ]
ASP.NET级联下拉列表(CSASPNETCascadingDropDownList) [ CascadingDropDown演示 [在ASP.NET MVC中级联DropDownList [在ASP.Net中创建级联DropDownList [将CascadingDropDown与数据库一起使用 [
If you are talking about cascading dropdownlist then check these
Selecting value in cascading dropdown list dynamically[^]
How to populate a dropdown list with another ddl[^]
Cascading DropDown - Country to state[^]
ASP.NET cascading drop-down-list (CSASPNETCascadingDropDownList)[^]
CascadingDropDown Demonstration[^]
Cascading DropDownList in ASP.NET MVC[^]
Creating Cascading DropDownLists in ASP.Net[^]
Using CascadingDropDown with a Database[^]
protected void ddlemployeeno_SelectedIndexChanged(object sender, EventArgs e)
{
ddlemployeename.Items.Clear();
//Fetch the records for all the employeename & employeeno in dataset
DataRow[] drEmployeeName = dsemployeeno.Tables[0].Select("EmployeeNo='" + ddlemployeeno.SelectedValue.ToString() + "'");
foreach (DataRow drrow in drEmployeeName)
{
ddlemployeename.Items.Add(new ListItem(drrow["name_of_column"].ToString(), drrow["name_of_column"].ToString()));
}
ddlemployeename.Items.Insert(0,new ListItem("-Select-"));
}
//首先,您应该获得第一个下拉列表的选定值
// Firstly u should get selected value of first dropdown
protected void ddlStateCode_SelectedIndexChanged(object sender, EventArgs e)
{
string strStateCode ="";
strStateCode = ddl1.SelectedValue;
// now u should send this value to database and get records according to this value and bind second dropdown with record
DataSet dsCity= new DataSet();
dsCity= obj.fnGetDetails("strStateCode");// Get city details according to state code
ddlCity.DataSource = dsCity.Tables[1];
ddlCity.DataValueField = "Code";
ddlCity.DataTextField = "Description";
ddlCity.DataBind();
ddlCity.Items.Insert(0, new ListItem("---Select City---", "0"));
}
谢谢
这篇关于dropdownlist选择的索引改变了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文