reorderlist - error when using with databound dropdownlist - unable to bind selectedvalue

Discussion in 'ASP .Net Web Controls' started by Mark Micallef, Apr 5, 2007.

  1. Hi, I'm having a problem using a databound dropdownlist inside a
    reorderlist ajax control. Here's a snippet of the code I'm using:

    <InsertItemTemplate>
    <div class="insertArea">
    <asp:DropDownList ID="lstUser" runat="server"
    DataSourceID="UserDataSource" DataTextField="UserName"
    DataValueField="UserId" SelectedValue='<%# Bind("UserId") %>'
    AppendDataBoundItems="true"></asp:DropDownList>
    <asp:TextBox ID="txtPhone" runat="server" MaxLength="20" Width="150"
    Text='<%# Bind("ContactPhone") %>'></asp:TextBox>
    <asp:TextBox ID="txtEmail" runat="server" MaxLength="255" Width="400"
    Text='<%# Bind("ContactEmail") %>'></asp:TextBox>
    <asp:Button ID="cmdAdd" runat="server" Text="Add"
    CommandName="insert" />
    </div>
    </InsertItemTemplate>

    When clicking the Add button, I get a "Databinding methods such as
    Eval(), XPath(), and Bind() can only be used in the context of a
    databound control."

    The bizarre thing about this is that the exact same code works fine in
    the EditItemTemplate. As far as I know, I need to bind the UserId so
    that it gets fed into the UserId parameter in the objectdatasource. If
    I remove the SelectedValue='<%# Bind("UserId") %>' part then I no
    longer get the error, but the objectdatasource tries to pass null for
    the userid to the database, which is of no use.

    Here is the insert section of the objectdatasource for reference:

    <InsertParameters>
    <asp:ControlParameter Name="Company" ControlID="lstCompany"
    PropertyName="SelectedValue" Type="Int32" />
    <asp:parameter Name="UserId" Type="Object" />
    <asp:parameter Name="Sequence" Type="Int32" />
    <asp:parameter Name="ContactPhone" Type="String" />
    <asp:parameter Name="ContactEmail" Type="String" />
    </InsertParameters>

    Hope to get some help on this as it's really bugging me.

    Regards,
    Mark
    Mark Micallef, Apr 5, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mr2_93
    Replies:
    1
    Views:
    3,575
    mr2_93
    Oct 2, 2005
  2. =?Utf-8?B?YW55ZW9uZQ==?=
    Replies:
    0
    Views:
    538
    =?Utf-8?B?YW55ZW9uZQ==?=
    Dec 19, 2005
  3. Mark Micallef
    Replies:
    0
    Views:
    630
    Mark Micallef
    Apr 5, 2007
  4. rodchar
    Replies:
    0
    Views:
    377
    rodchar
    Nov 26, 2007
  5. Lagrange
    Replies:
    1
    Views:
    541
    Lagrange
    Jan 17, 2009
Loading...

Share This Page