Problem with Details view

  • Thread starter Thread starter Cirene
  • Start date Start date
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>
<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>
 
i mean FORMVIEW :)

Cirene said:
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>
 
Back
Top