Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am having one Dataset name
dsUser
having below value

Data Set Column
USER_ID APP_USER_NAME FIRST_NAME   LAST_NAME FullName 


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 
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 & ")" 
If dsView is having more then one record then
I need to select that record into my dropdownlist
cboUsers


Please Suggest
Posted

1 solution

Hi,

you can use following code:

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



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

Thanks,
Imdadhusen
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900