DropDownList don't work inside ReorderList InsertItemTemplate ?

Last post 11-05-2009 3:38 PM by mahichandu. 8 replies.

Sort Posts:

  • DropDownList don't work inside ReorderList InsertItemTemplate ?

    08-17-2006, 9:07 AM
    • Member
      55 point Member
    • jods
    • Member since 06-01-2006, 2:35 PM
    • Posts 11
    In want to have a DropDownList inside the InsertItemTemplate of my ReorderList.

    Like this:
    <asp:DropDownList ID="NewRecipientsList" runat="server" Width="180px"
                                  DataSourceID="NewRecipientsSrc" DataTextField="UserName" DataValueField="UserId"
                                  SelectedValue='<%# Bind("UserId") %>' />


    But I get this error message at runtime:
    "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control."

    Which I don't understand. Using a TextBox instead works perfectly:
    <asp:TextBox ID="Test" runat="server" Text='<%# Bind("UserId") %>' />

    And using the dropdownlist in other controls, like FormView or DetailsView does work. I can't understand why the combination of ReorderList + DropDownList doesn't work.
  • Re: DropDownList don't work inside ReorderList InsertItemTemplate ?

    08-17-2006, 6:12 PM
    • Contributor
      4,346 point Contributor
    • sburke_msft
    • Member since 04-04-2006, 7:28 PM
    • Redmond, WA
    • Posts 770
    • AspNetTeam
    Are you sure that's causing the problem?  I just tried this with the ReorderList sample page and it worked fine - both in the EditTemplate and InsertTemplate.
    Don't forget, this posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: DropDownList don't work inside ReorderList InsertItemTemplate ?

    08-18-2006, 2:44 AM
    • Member
      55 point Member
    • jods
    • Member since 06-01-2006, 2:35 PM
    • Posts 11
    No, I'm not sure.
    As I said, I don't understand why this doesn't work. But I've noticed that replacing the DropDownList with a TextBox works.

    May it be that the error message is misleading ? The "UserId" I'm binding to is a SqlServer uniqueidentifier, could that be a problem ? (Although I think I tried to bind to UserName, which is a string, and it didn't work either)
  • Re: DropDownList don't work inside ReorderList InsertItemTemplate ?

    08-18-2006, 2:34 PM
    • Contributor
      4,346 point Contributor
    • sburke_msft
    • Member since 04-04-2006, 7:28 PM
    • Redmond, WA
    • Posts 770
    • AspNetTeam
    Are you sure it's not the binding of the DropDownList itself that's having problems?  Meaning I notice that it's also databound to another data source.
    Don't forget, this posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: DropDownList don't work inside ReorderList InsertItemTemplate ?

    08-21-2006, 9:31 AM
    • Member
      55 point Member
    • jods
    • Member since 06-01-2006, 2:35 PM
    • Posts 11
    Yes, I'm sure of that.
    If I simply remove the SelectedValue='<%# Bind("UserId") %>' attribute, the problem goes away (and the dropdown is correctly filled).
  • Re: DropDownList don't work inside ReorderList InsertItemTemplate ?

    09-18-2006, 1:34 PM
    • Member
      86 point Member
    • webman34
    • Member since 01-16-2004, 8:27 AM
    • Michigan
    • Posts 19

    I would like to know what I am doing wrong, too.  I am getting the same error.  Here is the code for my page:

     <h3>

    Sort and Add new Categories</h3>

    Select Parent Category to Sort:<br />

    <asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True" AutoPostBack="True"

    DataSourceID="CatListDataSource" DataTextField="CategoryName" DataValueField="CategoryID">

    <asp:ListItem Value="-1">&lt;Select Parent Category&gt;</asp:ListItem>

    <asp:ListItem Value="0">Top Level</asp:ListItem>

    </asp:DropDownList><br />

    <br />

    <asp:ObjectDataSource ID="CatListDataSource" runat="server" DeleteMethod="Deletecategory"

    InsertMethod="AddCategory" OldValuesParameterFormatString="{0}" SelectMethod="GetCategories"

    TypeName="Categories" UpdateMethod="UpdateCategory">

    <DeleteParameters>

    <asp:Parameter Name="categoryid" Type="Int32" />

    </DeleteParameters>

    <UpdateParameters>

    <asp:Parameter Name="categoryid" Type="Int32" />

    <asp:Parameter Name="categoryname" Type="String" />

    <asp:Parameter Name="parentcategoryid" Type="Int32" />

    <asp:Parameter Name="sortorder" Type="Int32" />

    </UpdateParameters>

    <InsertParameters>

    <asp:Parameter Name="categoryname" Type="String" />

    <asp:Parameter Name="parentcategoryid" Type="Int32" />

    <asp:Parameter Name="sortorder" Type="Int32" />

    </InsertParameters>

    </asp:ObjectDataSource>

    <atlas:ScriptManager id="MasterScriptManager" EnableScriptGlobalization="false" runat="Server">

    </atlas:ScriptManager>

    <cc1:reorderlist id="ReorderList1" runat="server" allowreorder="True" callbackcssstyle="callbackStyle"

    datakeyfield="categoryid" datasourceid="CatKidsDataSource" sortorderfield="sortorder" ItemInsertLocation="End">

    <ItemTemplate>

    <div class="itemArea">

    <b>Category: </b><asp:Label ID="Label4" runat="server" Text='<%# HttpUtility.HtmlEncode(Convert.ToString(Eval("CategoryName"))) %>'></asp:Label>

    </div>

    </ItemTemplate>

    <ReorderTemplate>

    <asp:Panel ID="Panel2" runat="server" CssClass="reorderCue">

    </asp:Panel>

    </ReorderTemplate>

    <InsertItemTemplate>

    <div style="padding-left:25px; border-bottom:thin solid transparent;border-top:thin solid transparent;">

    <asp:Panel ID="panel1" runat="server" DefaultButton="Button1">

    Insert a new Category here<br />

    Category Name<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="Category"

    ErrorMessage="Please enter a question" ValidationGroup="Insert">*</asp:RequiredFieldValidator>

    <asp:TextBox ID="Category" Text='<%# Bind("CategoryName")%>' runat="server"></asp:TextBox><br />

    Parent Category:<br />

    &nbsp;<asp:DropDownList ID="ParentName" runat="server" DataSourceID="CatList2DataSource"

    DataTextField="CategoryName" DataValueField="CategoryID" ValidationGroup="Insert" AppendDataBoundItems="True" SelectedValue='<%# Eval("ParentCategoryID") %>'>

    <asp:ListItem Value="0">Top Level</asp:ListItem>

    </asp:DropDownList><asp:ObjectDataSource ID="CatList2DataSource" runat="server" OldValuesParameterFormatString="original_{0}"

    SelectMethod="GetCategories" TypeName="Categories"></asp:ObjectDataSource>

    &nbsp;

    <asp:Button ID="Button1" runat="server" CommandName="Insert" Text="Add" ValidationGroup="Insert"></asp:Button>

    </asp:Panel>

    </div>

    </InsertItemTemplate>

    </cc1:reorderlist>

    <asp:ObjectDataSource ID="CatKidsDataSource" runat="server" InsertMethod="AddCategory"

    OldValuesParameterFormatString="original_{0}" SelectMethod="GetCategoriesByParent"

    TypeName="Categories" UpdateMethod="UpdateCategory" DeleteMethod="Deletecategory">

    <UpdateParameters>

    <asp:Parameter Name="categoryid" Type="Int32" />

    <asp:Parameter Name="categoryname" Type="String" />

    <asp:Parameter Name="parentcategoryid" Type="Int32" />

    <asp:Parameter Name="sortorder" Type="Int32" />

    </UpdateParameters>

    <SelectParameters>

    <asp:ControlParameter ControlID="DropDownList1" Name="parentid" PropertyName="SelectedValue"

    Type="Int32" />

    </SelectParameters>

    <InsertParameters>

    <asp:Parameter Name="categoryname" Type="String" />

    <asp:Parameter Name="parentcategoryid" Type="Int32" />

    <asp:Parameter Name="sortorder" Type="Int32" />

    </InsertParameters>

    <DeleteParameters>

    <asp:Parameter Name="categoryid" Type="Int32" />

    </DeleteParameters>

    </asp:ObjectDataSource>

    Thanks!

    Brad
  • Re: DropDownList don't work inside ReorderList InsertItemTemplate ?

    08-22-2007, 1:14 PM
    • Member
      2 point Member
    • EvilTed
    • Member since 03-29-2005, 9:01 PM
    • Rochester, MN
    • Posts 1

    I had the same problem.  To get around the problem I added some hidden fields that the dropdown updated, and bound the hidden fields and this worked for me:

    <InsertItemTemplate>

    <!-- bottom border is workaround for IE7 Beta issue where bg doesn't render -->

    <div style="padding-left:25px; border-bottom:thin solid transparent;">

    <asp:Panel ID="panel1" runat="server" DefaultButton="Button1">

    <asp:DropDownList ID="DDLResources" runat="server"

    OnPreRender="DDLResources_PreRender" ValidationGroup="Add" OnSelectedIndexChanged="DDLResources_SelectedIndexChanged" />

    <asp:HiddenField ID="hdnResourceId" runat="server" value='<%# Bind("ResourceId") %>' />

    <asp:HiddenField ID="hdnResourceCode" runat="server" value='<%# Bind("ResourceCode") %>' />

    <asp:Button ID="Button1" runat="server" CommandName="Insert" Text="Add" ValidationGroup="Add"/>

    </asp:Panel>

    </div>

    </InsertItemTemplate>

  • Re: DropDownList don't work inside ReorderList InsertItemTemplate ?

    08-03-2008, 12:55 PM
    • Member
      6 point Member
    • rochasman
    • Member since 05-30-2003, 2:26 PM
    • İstanbul
    • Posts 3

    I have same issue. and I cant reach dropdownlist from codebehind. its returning null. any idea?

    http://bisikletciler.com
  • Re: DropDownList don't work inside ReorderList InsertItemTemplate ?

    11-05-2009, 3:38 PM
    • Member
      39 point Member
    • mahichandu
    • Member since 05-21-2009, 3:10 PM
    • Posts 139

     

    Hey i ahve the same problem. can you look into my QQ.i copied below.

     I got a QQ on AJAX Reorderlist Itemtemplate.

    I am using two reorderlist controls with in a page. Reorderlis1 contains pending records. I just load the pending records. the records can be moved from Reorderlist 1 to Reordrlist 2 with add button. In this table I am not doing reordering .

    Reorderlist2 contains Queued records. In this I will do the reordering, the records which are there in Reorderlist 2 , transfer the records into the tasktable. In this table I have the cancel button also. If user don’t want to update some records they can moved back those records from Recorder list 2 to Recorderlist 1. I am done with this part. My 1st QQ:

    Now I added Dropdownlist control to the Reorderlist 1 Item tamplate. Item template dropddownlist is my user control.My dropdown list contains the list of years. So I am calling my Usercontrol method with the Itrmtamplate dropdownlist ID. Here I got below error. 'ddlbeginyod1' is my Reorderlist Item template dropdownlist ID Text. Why??

    Error:The name 'ddlbeginyod1' does not exist in the current context.

    I tried adding the dropdownlist in insertitem template also. There also I got the same issue.

    I never worked with Ajax Reorderlist control. I am very confused with this control.

     I can add Dropdown list to the Reordrlist Itemtamplate right ? If I can add the dropdownlist into the item template I have 2nd QQ?

    • If I can load the dropdownlist. For each row I will be having the year dropdownlist right. When user selects first row and moved from the reorderlist1 to reorderlist 2 with add button. he has to select the year of that row.

    I need to send year value by each row to task table. Can I do that with reorderlist item template.How can I store the year value.If so, how can I do that? Please any one know the answer ,,please suggest me … Its really important to me.

    I copying my 1st reorderlist design page below,

    <ajax:ReorderList runat="server" CssClass="ReOrderList" ID="rolpendsearch" Width="370" ToolTip="Records To be imported"

    AllowReorder="true" PostBackOnReorder="true" DataKeyField="InputFileID" ItemInsertLocation="End" EnableViewState="true"> 

    <ItemTemplate>

    <div class="ItemTemplate" align="right">

    <td> <users:DeathYearDropdownList runat="server" ID="ddlbeginyod1" OnSelectedIndexChanged="ddlbeginyod1_OnSelectedIndexChanged" /> </td>

    <td><users:DeathYearDropdownList runat="server" ID="ddlendyod1" OnSelectedIndexChanged="ddlendyod1_OnSelectedIndexChanged" /> </td> <td> <asp:Button runat="server" ID="btnsearch" CommandArgument='<%#Eval("InputFileID")%>' Visible=true

    CssClass="button" ToolTip="Add To Search Queue" Text="To Search Queue" OnClick="btnsearch_Click" /></td></div>

    </ItemTemplate>

    <InsertItemTemplate>

    <div class="ItemTemplate" align="right">

    <td> <users:DeathYearDropdownList runat="server" ID="ddlbeginyod1" OnSelectedIndexChanged="ddlbeginyod1_OnSelectedIndexChanged" /> </td>

    </div></InsertItemTemplate>

    <EmptyListTemplate>

    <asp:Panel ID="Panel2" runat="server" CssClass="ItemTemplate" Width="330px" >

    <table width="330Px" title="No Records Queued to Add." summary="No Records Queued to Add.">

    <tr title="No Records Queued to Add."> <th title="No Records Queued to Add.">

    <th title="No Records Queued to Add."><b>No Records Queued to Add.</b></th>

    </tr>

    </table>

    </asp:Panel>

    </EmptyListTemplate> 

    <ReorderTemplate>

    <asp:Panel ID="Panel1" runat="server" Width="400px" CssClass="ReorderTemplate" />

    </ReorderTemplate> 

    <DragHandleTemplate>

    <table class="DragHandleTemplate" style="width:350px;text-align:left;" align="left"

    summary="<%# GetToolTip1("FileName:" +Eval("InputFileName").ToString() )%>"

    title="<%# GetToolTip1("FileName:" +Eval("InputFileName").ToString())%>">

    <tr>

    <td><asp:Label ToolTip='<%# GetToolTip1("FileName:" +Eval("InputFileName").ToString())%>' runat="server" ID="fname" Text='<%#Eval("CustName")%>' /></td>

    <td><asp:Label ToolTip= "Records" runat="server" ID="Rowcount" Text='<%# "Records:" +Eval("IFRowCt")%>' /></td>

    </tr> 

    </table>

    </DragHandleTemplate> 

    </ajax:ReorderList>

     

     

Page 1 of 1 (9 items)