Use Bind to select multiple values in listbox?

4 posts, 0 answers
  1. William Corry
    William Corry avatar
    21 posts
    Member since:
    Feb 2009

    Posted 25 Mar 2009 Link to this post

    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.
  2. Todd Anglin
    Todd Anglin avatar
    2040 posts
    Member since:
    Aug 2005

    Posted 26 Mar 2009 Link to this post

    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!

  3. DevCraft R3 2016 release webinar banner
  4. Do Xuan
    Do Xuan avatar
    16 posts
    Member since:
    Aug 2011

    Posted 05 May 2013 Link to this post

    i can't understand Bind("field", "format string {0}"). can you go to the details, plz!
  5. Daniel
    Daniel avatar
    4933 posts

    Posted 08 May 2013 Link to this post

    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,
    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.
Back to Top