This is a migrated thread and some comments may be shown as answers.

Use Bind to select multiple values in listbox?

3 Answers 176 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
William Corry
Top achievements
Rank 1
William Corry asked on 25 Mar 2009, 12:40 PM
I have created a usercontrol to edit the values on a RadGrid.  One of the fields on the grid is stored in the database as a comma separated string.  In order to allow the user to change the stored values for this field, a multiselect listbox has been placed on the usercontrol.  Currently I use the edit event to store the currentvalues in this field in a session variable.  Then on the databound event, I retrieve the value from the session variable, parse them and select the appropriate rows in the listbox to show what the past values were.  The code works but I was wondering if there was any way to use the bind statement to effect the same end?  If there is only one value to be selected the bind will work but if more than one value is to be selected I don't know of or how the bind statement would work.

3 Answers, 1 is accepted

Sort by
0
Todd Anglin
Top achievements
Rank 2
answered on 27 Mar 2009, 04:41 AM
Hello William-

As far as I know, you cannot declaratively use the ASP.NET Bind() syntax to do two-way binding with multiple fields. According to what I can find in some quick research, too, the only supported formats for Bind() are:

Bind("field") and Bind("field", "format string {0}")

I think the code-behind solution that's working for you now is the correct approach for this scenario. Hope that helps!

-Todd
0
Do Xuan
Top achievements
Rank 1
answered on 05 May 2013, 02:52 PM
i can't understand Bind("field", "format string {0}"). can you go to the details, plz!
0
Daniel
Telerik team
answered on 08 May 2013, 01:35 PM
Hello Do Xuan,

I would recommend that you examine the following links:
Data-Binding Expressions Overview
How ASP.NET databinding deals with Eval() and Bind() statements
Bind, Eval, Container.DataItem

Best regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
General Discussions
Asked by
William Corry
Top achievements
Rank 1
Answers by
Todd Anglin
Top achievements
Rank 2
Do Xuan
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or