General .NETFor general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums. If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category.
** PLEASE BE SPECIFIC WITH YOUR QUESTION **
When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
Hi,
I have a registration form where i am using a listbox where we can select multiple values.I am storing these values concatenating with commas(for eg. A,B,C).Now i have to update this registration form, so i have to retrieve these values and to hightlight the previously selected values.
I have the idea that first i have to retrieve that field from database and split the commas and then i have to write the code in the front end to display the values.
But in real time i m unable to display in front end.
Can anyone help me.
This will work to highlight if the values are individually stored, but in my case all the values are stored with commas. Like A,B,C,
I have to highlight only those values not all the values.
What u suggest for this.
I guess you can still use this. First split the comma seperated string into an array. Then build a custom logic to highlight the listbox based on this array element.
Of course I can use this, but if I write all these then its highlighting all the list items not only the selected one. I have to hightlight the selected items from the list after retrieving from the database.
In these code, the first one is a function, in which you need to pass your drop down control name and the string which you need to find the index. It will give you the selectedindex of the item in the listbox. I got success using this code. Tell me if you face any problem in these. [Hope you have string after spliting, pass the string into the function].
I tried your code but it did not work for me. I did not understood what ds_GetRequest is. Any way I have the following code to bind the data from a table to listbox. I too know i have use split function. But dont know how to fit that.
Sub ListLoad()
' ||||| DECLARE VARIABLES |||||
Dim strProducts As String = "select swinstalled from a_desktops where assetcode='" & TextBox1.Text & "'"
Dim Cmd As New SqlCommand(strProducts, dbconn)
Dim objReader As SqlDataReader
Dim objReader As SqlDataReader
Dim delimStr As String = ","
Dim delimiter As Char() = delimStr.ToCharArray()
Dim s As String
For Each s In strProducts.Split(delimiter)
Response.Write((s.ToString() + "<br>"))
Dim Cmd As New SqlCommand(mystring, dbconn)
Next
Try
If dbconn.State = ConnectionState.Closed Then
dbconn.Open()
End If
objReader = Cmd.ExecuteReader(CommandBehavior.CloseConnection)
lstselectedemployees.Items.Clear()
lstselectedemployees.DataTextField = "Swinstalled"
lstselectedemployees.DataSource = objReader
lstselectedemployees.DataBind()
objReader.Close()
Catch ex As Exception
MsgBox("Error Connecting to Database!", MsgBoxStyle.Critical)
End Try