Adding information to a dropdownlist from a dataset

L

Lennie

Hello.


i have tree dropdownlist that i want to add some information from a databas.
The sql questions is like this for the tree dropdownlist´s

SELECT distinct eventuser
FROM syslog..tblsecurityEvents
where eventuser like 'PHONERA%' and eventuser not like '%$'

SELECT distinct eventuser
FROM syslog..tblsecurityEvents
where eventuser like 'PHONERA%' and eventuser like '%$'

SELECT distinct eventuser
FROM syslog..tblsecurityEvents
where eventuser not like 'PHONERA%'

but.. I don't want to make 3 dataset.
Can I just do one dataset like this.

SELECT distinct eventuser
FROM syslog..tblsecurityEvents

And the use some type off dataview or something else to sort the information
on the right dropdownlist.
The code I am using right now is something like

Dim show_users As SqlDataAdapter = New SqlDataAdapter("SELECT distinct
eventuser FROM syslog..tblsecurityEvents where eventuser like 'PHONERA%' and
eventuser not like '%$'", connect1)

show_users.Fill(PortalData, "eventuser")

DropDownList1.DataSource = PortalData
DropDownList1.DataMember = ("eventuser")
DropDownList1.DataTextField = ("eventuser")
DropDownList1.DataBind()

// Lennie
Phonera.se
 
M

Miha Markic

Hi Lennie,

Yes, you could use DataView.
Just create a DataView (for each dropdown) with filter and use it as a
datasource.
 
M

Miha Markic

Hi Lennie,

Something like:
Dim dv as DataView = new DataView(ds.Tables("eventuser"), "Colum1 = 1 AND
Column2 LIKE 'AAA%'", "Column1 ASC", DataViewRowState.CurrentRows)

DropDownList1.DataSource = dv
// no datamemeber
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top