刷新下拉列表中的数据 [英] Refreshing data in dropdownlist

查看:97
本文介绍了刷新下拉列表中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个下拉列表.第二个下拉列表从第一个下拉列表接收值以显示数据,但是我有一个问题,在从第一个下拉列表中选择拳头之后,第二个下拉列表数据无法刷新以从第一个下拉列表中提供新数据,我在第一个下拉列表中使用了自动回发功能,但是我不知道选择更改该怎么写?

I have 2 dropdownlist .that second dropdown list receives value from first one to show data,but I have a problem that after fist selection from first dropdown seconde dropdown data can not refresh to gives new data from first drop down list,I used auto post back in first dropdown list but I dont know what can I write in selecting changes?

推荐答案

您需要在保存,更新或更新时调用DataBind()函数删除数据.
就像
DropDownList.DataBind();
要获得更多参考,请在那里看看
MSDN- [DropDownList类] [ MSDN- [BaseDataBoundControl.DataBind方法] [
You need to call DataBind() function while saving,updating or deleting data.
like
DropDownList.DataBind();
To get more reference Have a look there
MSDN-[DropDownList Class][^]
MSDN-[BaseDataBoundControl.DataBind Method][^]


好吧,我不确定. ...关于你的事情....
但这会工作.....
在Page load上尝试这个
< pre lang ="c#">
受保护的void Page_Load(对象发送者,EventArgs e)
{
字符串s = DropDownList1.SelectedItem.ToString();

DropDownList2.Items.Add(s);

}
</pre>
Well I am Not Sure.....about ur thing....
but this will work.....
try this one on Page load
<pre lang="c#">
protected void Page_Load(object sender, EventArgs e)
{
string s = DropDownList1.SelectedItem.ToString();

DropDownList2.Items.Add(s);

}
</pre>


在添加新项之前尝试清除DropDownList的旧项.
Try to clear the old items of DropDownList before adding new Items in it.
DropDownList1.Items.Clear();


这篇关于刷新下拉列表中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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