如何刷新DropDownList [英] How can I refresh a DropDownList

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

问题描述




我有一个带有一个DropDownList的Web表单,它从表中读取它的数据。

我旁边有一个按钮DropDownList运行'是一个插入查询来向表中添加一个新项。

到现在为止每件事情都很好,但我现在需要刷新DropDownList并自动选择新插入的项目。



希望解决这个问题

谢谢

Hi
I have a web Form with one DropDownList which read it''s data from a table.
and I have a button next to the DropDownList which run''s an insert query to add a new item to the table.
Until now every thing is fine, but what I need now is to refresh the DropDownList and automatically select the new inserted item.

Hope to solve this problem
Thank you

推荐答案

在将数据插入数据库表之前,将值存储在某个变量中





for ex。

Before insert the data to the database table, store the value in some variable


for ex.
<br />
Dim strNewValue


=新数据< br />
< br />
InsertDatabase(新数据)''Ur要在数据库中插入的功能< br />
< br />
Dim dt as datatable = drpYourdropdown.datasource< br />
Dim dr as datarow< br />
dr = dt.NewRow()< br />
dr.Item(0)= strNewValue< br />
dt.add(dr)< br />
drpYourDropdown.datasource = dt< br />
drpYOurDropdown.databind()< br />
< br />
="New Data"<br /> <br /> InsertDatabase("New Data") ''Ur functionality to insert in database<br /> <br /> Dim dt as datatable = drpYourdropdown.datasource<br /> Dim dr as datarow<br /> dr=dt.NewRow()<br /> dr.Item(0)=strNewValue<br /> dt.add(dr)<br /> drpYourDropdown.datasource=dt<br /> drpYOurDropdown.databind()<br /> <br />





试试以上代码......



Try the above code...


这篇关于如何刷新DropDownList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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