DatabaseDude
Programmer
This is probably so simple that I'll beat myself repetitively after learning the answer
Problem: I have a listbox, lstUrls, that is populated by a dataset. It contains a list of web sites. And there is a button, btnRemove, that attempts to recognize the currently selected record in lstUrls. However ... it always returns a blank value.
Code for populating/binding lstUrls:
FWIW "UserModlueID" is the correct spelling of the database field, at least the way it's currently spelled.
And the OnClick code for btnRemove:
Thinking it's just a minor syntax thing - thanks in advance for taking a look at this for me!
Problem: I have a listbox, lstUrls, that is populated by a dataset. It contains a list of web sites. And there is a button, btnRemove, that attempts to recognize the currently selected record in lstUrls. However ... it always returns a blank value.
Code for populating/binding lstUrls:
Code:
Dim Conn As New SqlConnection(ConfigurationManager.ConnectionStrings("StiApps").ConnectionString)
Try
Conn.Open()
Dim CommUrlsAssigned As New SqlCommand
With CommUrlsAssigned
.CommandText = "dbo.spGetAssignedUserUrls"
.Connection = Conn
.CommandType = CommandType.StoredProcedure
.Parameters.AddWithValue("@StrUserName", StrUserName)
End With
Dim DaUrlsAssigned As SqlDataAdapter = New SqlDataAdapter
DaUrlsAssigned.SelectCommand = CommUrlsAssigned
Dim DsUrlsAssigned As DataSet = New DataSet
DaUrlsAssigned.Fill(DsUrlsAssigned, "AssignedUrls")
With Me.lstUrls
.DataSource = DsUrlsAssigned
.DataMember = "AssignedUrls"
.DataValueField = "UserModlueID"
.DataTextField = "LinkName"
.DataBind()
End With
Conn.Close()
Catch ex As Exception
MsgBox(ex.ToString)
Finally
End Try
FWIW "UserModlueID" is the correct spelling of the database field, at least the way it's currently spelled.
And the OnClick code for btnRemove:
Code:
Response.Write(Me.lstUrls.SelectedValue)
Thinking it's just a minor syntax thing - thanks in advance for taking a look at this for me!