如何在asp.net中的下拉列表的选定文本上调用函数 [英] How to call function on selected text of dropdownlist in asp.net
问题描述
如何调用此代码上的函数
DropDownList4.SelectedItem.Text =?
I有一个登记表。我已经制作了级联下拉列表,其中状态下拉列表的数据被加载到国家的选定索引更改。 sql数据库有表Country和State。
我正在加载所有数据(其他页面,就像这里是编辑配置文件),这是在各个文本框和下拉列表中的页面加载事件的注册期间提交的。问题是国家在国家下拉菜单上完全加载,但各州的价值没有在州下降时加载。
我使用的代码如下所示< br $> b $ b
how to call function on this code
DropDownList4.SelectedItem.Text = ?
I have one registration form. I have made cascading dropdownlist in which data of state dropdownlist is loaded on selected index change of Country. sql database is having table Country and State.
I am loading all data(other page, like here it is edit profile) which was submitted during registration on page load event at respective textboxes and dropdownlist. The problem is that Country is loading perfectly on country dropdown but the value of respective state is not loading on state drop down.
code that i am using is as below
protected void loadinternshipdata()
{
SqlConnection con = new SqlConnection("Data Source=ja-pc\\sqlexpress;Initial Catalog=Internship;Integrated Security=True;Pooling=False");
con.Open();
SqlCommand cmd3 = new SqlCommand("select * from Internship where CompanyID=" + Convert.ToInt16(Session["CompanyID"].ToString()), con);
SqlDataAdapter daa = new SqlDataAdapter(cmd3);
DataTable dtt = new DataTable();
daa.Fill(dtt);
if (dtt.Rows.Count > 0)
{
DropDownList3.SelectedItem.Text = dtt.Rows[0]["Country"].ToString();
DropDownList4.SelectedItem.Text = dtt.Rows[0]["State"].ToString();
}
}
推荐答案
public void DropDownList_selectionindexchanged()
{
public void DropDownList_selectionindexchanged()
{
if (DropDownList4.SelectedItem.Text == ?)
{
yourfunction();
}
}
yourfunction()
{
}
}
yourfunction()
{
}
这篇关于如何在asp.net中的下拉列表的选定文本上调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!