C
Cirene
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>
<aspropDownList ID="ddlCatInsert"
runat="server" AutoPostBack="True"
DataSourceID="sdsCategories"
DataTextField="Category" DataValueField="Id"</aspropDownList>
<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>
<aspropDownList ID="DropDownList1"
runat="server"
DataSourceID="sdsSubCategories"
DataTextField="SubCategory" DataValueField="Id"
SelectedValue='<%# Bind("SubcategoryId")
%>'>
</aspropDownList>
</td>
</tr>
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>
<aspropDownList ID="ddlCatInsert"
runat="server" AutoPostBack="True"
DataSourceID="sdsCategories"
DataTextField="Category" DataValueField="Id"</aspropDownList>
<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>
<aspropDownList ID="DropDownList1"
runat="server"
DataSourceID="sdsSubCategories"
DataTextField="SubCategory" DataValueField="Id"
SelectedValue='<%# Bind("SubcategoryId")
%>'>
</aspropDownList>
</td>
</tr>