J
Joey
Hi,
I'm trying to add a default item to my listbox but when I do it tells me
that it's not defined, could someone tell me the syntax I need to use to get
the listbox control to display a default item?
I have tried the following:
lstStates.Items.Insert(0, new ListItem("By State","0"))
ME.lstStates.Items.Insert(0, new ListItem("By State","0"))
Joey
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs)
CategoryID = Cint(request.querystring("CategoryID"))
If Not Page.IsPostBack() Then
lstStates.DataSource = BindStates
lstStates.DataValueField = "LocationID"
lstStates.DataTextField = "Location"
' lstStates.Items.Insert(0, new ListItem("By State","0"))
lstStates.SelectedIndex = 0
lstStates.DataBind()
lstCategorie.DataSource = BindCategories
lstCategorie.DataValueField = "CategoryID"
lstCategorie.DataTextField = "CategoryDesc"
'lstCategorie.Items.Insert(0, new ListItem("By Category","0"))
lstCategorie.SelectedIndex = 0
lstCategorie.DataBind()
BindTheData(CategoryID)
End If
End Sub
I'm trying to add a default item to my listbox but when I do it tells me
that it's not defined, could someone tell me the syntax I need to use to get
the listbox control to display a default item?
I have tried the following:
lstStates.Items.Insert(0, new ListItem("By State","0"))
ME.lstStates.Items.Insert(0, new ListItem("By State","0"))
Joey
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs)
CategoryID = Cint(request.querystring("CategoryID"))
If Not Page.IsPostBack() Then
lstStates.DataSource = BindStates
lstStates.DataValueField = "LocationID"
lstStates.DataTextField = "Location"
' lstStates.Items.Insert(0, new ListItem("By State","0"))
lstStates.SelectedIndex = 0
lstStates.DataBind()
lstCategorie.DataSource = BindCategories
lstCategorie.DataValueField = "CategoryID"
lstCategorie.DataTextField = "CategoryDesc"
'lstCategorie.Items.Insert(0, new ListItem("By Category","0"))
lstCategorie.SelectedIndex = 0
lstCategorie.DataBind()
BindTheData(CategoryID)
End If
End Sub