Problem with Details view

Discussion in 'ASP .Net' started by Cirene, May 10, 2008.

  1. Cirene

    Cirene Guest

    I have a detailsview control. In theInsertItemTemplate I have 2 cascade
    dropdownlists (for category and subcategory). For the 2nd one (subcategory)
    I tried to do a databind to a field but I get this error:

    Databinding methods such as Eval(), XPath(), and Bind() can only be used in
    the context of a databound control.

    Any ideas why? Here's part of the html code...

    <InsertItemTemplate>
    <table class="style3">
    <tr>
    <td class="style4">
    Category:</td>
    <td>
    <asp:DropDownList ID="ddlCatInsert"
    runat="server" AutoPostBack="True"
    DataSourceID="sdsCategories"
    DataTextField="Category" DataValueField="Id"
    >

    </asp:DropDownList>
    <asp:SqlDataSource ID="sdsCategories"
    runat="server"
    ConnectionString="<%$
    ConnectionStrings:ConnectionString %>"
    SelectCommand="SELECT * FROM
    [classifiedCategories] ORDER BY [Category]">
    </asp:SqlDataSource>
    </td>
    </tr>
    <tr>
    <td class="style4">
    Subcategory:</td>
    <td>
    <asp:SqlDataSource ID="sdsSubCategories"
    runat="server"
    ConnectionString="<%$
    ConnectionStrings:ConnectionString %>"
    SelectCommand="SELECT * FROM
    [classifiedSubcategories] WHERE ([CategoryId] = @CategoryId)">
    <SelectParameters>
    <asp:ControlParameter
    ControlID="ddlCatInsert" Name="CategoryId"
    PropertyName="SelectedValue"
    Type="Int32" />
    </SelectParameters>
    </asp:SqlDataSource>
    <asp:DropDownList ID="DropDownList1"
    runat="server"
    DataSourceID="sdsSubCategories"
    DataTextField="SubCategory" DataValueField="Id"
    SelectedValue='<%# Bind("SubcategoryId")
    %>'>
    </asp:DropDownList>
    </td>
    </tr>
     
    Cirene, May 10, 2008
    #1
    1. Advertising

  2. Cirene

    Cirene Guest

    i mean FORMVIEW :)

    "Cirene" <> wrote in message
    news:...
    >I have a detailsview control. In theInsertItemTemplate I have 2 cascade
    >dropdownlists (for category and subcategory). For the 2nd one
    >(subcategory) I tried to do a databind to a field but I get this error:
    >
    > Databinding methods such as Eval(), XPath(), and Bind() can only be used
    > in the context of a databound control.
    >
    > Any ideas why? Here's part of the html code...
    >
    > <InsertItemTemplate>
    > <table class="style3">
    > <tr>
    > <td class="style4">
    > Category:</td>
    > <td>
    > <asp:DropDownList ID="ddlCatInsert"
    > runat="server" AutoPostBack="True"
    > DataSourceID="sdsCategories"
    > DataTextField="Category" DataValueField="Id"
    > >

    > </asp:DropDownList>
    > <asp:SqlDataSource ID="sdsCategories"
    > runat="server"
    > ConnectionString="<%$
    > ConnectionStrings:ConnectionString %>"
    > SelectCommand="SELECT * FROM
    > [classifiedCategories] ORDER BY [Category]">
    > </asp:SqlDataSource>
    > </td>
    > </tr>
    > <tr>
    > <td class="style4">
    > Subcategory:</td>
    > <td>
    > <asp:SqlDataSource ID="sdsSubCategories"
    > runat="server"
    > ConnectionString="<%$
    > ConnectionStrings:ConnectionString %>"
    > SelectCommand="SELECT * FROM
    > [classifiedSubcategories] WHERE ([CategoryId] = @CategoryId)">
    > <SelectParameters>
    > <asp:ControlParameter
    > ControlID="ddlCatInsert" Name="CategoryId"
    > PropertyName="SelectedValue"
    > Type="Int32" />
    > </SelectParameters>
    > </asp:SqlDataSource>
    > <asp:DropDownList ID="DropDownList1"
    > runat="server"
    > DataSourceID="sdsSubCategories"
    > DataTextField="SubCategory" DataValueField="Id"
    > SelectedValue='<%# Bind("SubcategoryId")
    > %>'>
    > </asp:DropDownList>
    > </td>
    > </tr>
    >
    >
     
    Cirene, May 10, 2008
    #2
    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. =?Utf-8?B?Sm9l?=

    Show Details/Hide Details link button

    =?Utf-8?B?Sm9l?=, Mar 13, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    910
    dkode
    Mar 13, 2006
  2. Microsoft News Group

    Problem With Custom Validation In a Details View

    Microsoft News Group, Aug 8, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    4,141
    Microsoft News Group
    Aug 9, 2006
  3. Bishop

    Details View Problem

    Bishop, Jan 8, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    289
    Bishop
    Jan 8, 2007
  4. kenner

    Objectlist Details View problem

    kenner, Mar 15, 2005, in forum: ASP .Net Mobile
    Replies:
    0
    Views:
    117
    kenner
    Mar 15, 2005
  5. Parthiv Joshi
    Replies:
    1
    Views:
    708
    Samuel L Matzen
    Jul 6, 2004
Loading...

Share This Page