只要文本框值发生变化,就需要更改DropBoxList [英] DropBoxList need to change whenever there is change in the textbox value

查看:58
本文介绍了只要文本框值发生变化,就需要更改DropBoxList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据集名称

dsUser

的值低于值

数据集列

having below value

Data Set Column

USER_ID APP_USER_NAME FIRST_NAME   LAST_NAME FullName 



我将此数据集存储到DropDownList



I am storing this Dataset into DropDownList

cboUsers

With cboUsers
            .DataSource = dsUser
            .DataTextField = "FullName"
            .DataValueField = "User_Id"
            .DataBind()


结尾为
而且我添加了一个文本框


End With
And I have added one textbox

txtNTID 

,用于在dsUser DataSet中查找值
现在,我将使用DataView dsView将文件管理器应用于上述数据集,以检查是否正在将记录搜索到表中(我正在将APP_USR_NAME传递给搜索标准)

for finding the value in dsUser DataSet
Now I am applying the filer to above dataset using DataView dsView to check wather I am having searching record into the table or not (I am passing APP_USR_NAME) to the searching critera

FilterCondition
            dsView = dsUser.Tables(0).DefaultView
            strFilterClause = "APP_USER_NAME=''" & Trim(txtNTID.Text.ToString()) & "''"
            dsView.RowFilter = "(" & strFilterClause & ")" 

如果dsView有一个以上的记录,则
我需要将该记录选择到我的下拉列表

If dsView is having more then one record then
I need to select that record into my dropdownlist

cboUsers



请提出建议



Please Suggest

推荐答案



您可以使用以下代码:

Hi,

you can use following code:

for (int i = 1; i < dsView.Count; i++)
           {
               cboUsers.Items.Add(new ListItem(dsView[i]["FullName"], dsView[i]["User_Id"]));
           }




注意:如果您的记录过滤器有多个记录,则它将添加其他记录,否则将跳过循环.

谢谢,
Imdadhusen




Note: If your record filter has more than one record then it will add records other wise it skips for loop.

Thanks,
Imdadhusen


这篇关于只要文本框值发生变化,就需要更改DropBoxList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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