Click here to Skip to main content
14,160,515 members
Rate this:
 
Please Sign up or sign in to vote.
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

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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"]));
           }



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

Thanks,
Imdadhusen
   

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web02 | 2.8.190518.1 | Last Updated 26 Jul 2010
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100