dropdown list box

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

I have a list box that is bound to a table and displays names. I would like
to have it also display and item that is not in the DB

I want it to display an option for ALL, and still display the names? How can
i do this in C#/ASP.NET
 
<<I have a list box that is bound to a table and displays names. I would
like
to have it also display and item that is not in the DB

I want it to display an option for ALL, and still display the names? How
can
i do this in C#/ASP.NET>>

I have it in VB, but this works for me:

' do a databind to select items to display.



If lbRG.Items.Count > 0 Then

Dim txtRGAll As String

txtRGAll = "All Report Groups in " & BA

lbRG.Items.Insert(0, txtRGAll)

lbRG.Items(0).Value = "0"

End If

lbRG.Rows = lbRG.Items.Count

Dim x As Integer

If lbRG.SelectedIndex > -1 Then

For x = 0 To lbRG.Items.Count - 1

If lbRG.Items(x).Value = sSelect Then

lbRG.SelectedIndex = x

End If

Next

End If

Basically, I just insert a record in the listbox at Zero. In the onclick
event for the next one you'll have to monitor for it selecting all of the
items in that listbox.

SC
 
Hi,
I have tried doing this with drop down lists....it might be similar for
listbox also...heres wat i did,,.

ddl1.DataSource=dr;
..
..
ddl1.Databind();
ddl1.Items.Add("All");
This will add all to the dropdownlist in addition to watever the
datasource provides.

HTH,
Ben
 
Back
Top