我在DetailsView中有两个下拉列表,我想在级联中工作,想法是一个区域包含各种问题,这些问题取决于所选区域,但是我收到以下错误:
数据绑定方法(如Eval(),XPath()和Bind())只能在数据绑定控件的上下文中使用。
在下一行:
<asp:DropDownList ID="ddlIssue" runat="server"
DataTextField="NameIssue" DataValueField="IdIssue"
完整的代码是:
<asp:TemplateField HeaderText="Area" SortExpression="IdArea">
<EditItemTemplate>
<asp:DropDownList ID="ddlArea" runat="server"
DataSourceID="SqlDataSource145711" DataTextField="NameArea"
DataValueField="IdArea" AutoPostBack="true"
AppendDataBoundItems="true" SelectedValue='<%# Bind("IdArea") %>'>
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource145711" runat="server"
ConnectionString="<%$ ConnectionStrings:BaseDatosCJConnectionString %>"
SelectCommand="SELECT IdArea, NameArea FROM AREA">
</asp:SqlDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server"
Text='<%# Bind("IdArea") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Issue">
<EditItemTemplate>
**<asp:DropDownList ID="ddlIssue" runat="server"
DataTextField="NameIssue" DataValueField="IdIssue"**
DataSourceID="SqlDataSource22" SelectedValue='<%# Bind("IdIssue") %>'
</asp:DropDownList>
<asp:SqlDataSource runat="server"
ID="sqlDataSource22"
ConnectionString="<%$ ConnectionStrings:BaseDatosCJConnectionString %>"
SelectCommand="SELECT IdIssue, NameAIssue, IdArea FROM ISSUE"
FilterExpression="IdArea = '{0}'">
<FilterParameters>
<asp:ControlParameter Name="Param" ControlID="ddlArea"
PropertyName="SelectedValue" />
</FilterParameters>
</asp:SqlDataSource>
</EditItemTemplate>
</asp:TemplateField>
你能帮忙解决这个错误吗?
我必须从代码中做一些事情吗?
祝福
答案 0 :(得分:0)
您不希望问题区域看起来像这样:
<asp:DropDownList ID="ddlIssue" runat="server"
DataTextField="NameIssue" DataValueField="IdIssue"
DataSourceID="SqlDataSource22" SelectedValue='<%# Bind("IdIssue") %'>
请注意,撇号'
会在结束时发生。