过滤后数据绑定的主要详细信息下拉错误(类别/子类别) [英] Master details dropdown error with data binding after filtration (Category / Subcategory)

查看:96
本文介绍了过滤后数据绑定的主要详细信息下拉错误(类别/子类别)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

>过滤后数据绑定的主要细节下拉错误(类别/子类别)

我需要帮助解决问题。两个下拉列表都是FormView的一部分,也是InsertItemTemplet的一部分。第一个选择Category(我检查了autopostback)第二个下拉子类别仅过滤每个categoryID匹配的记录。下拉子类别从表中获取数据(Subcategory_ID,Subcategory,Category_ID)

它们通过控制类别下拉列表Where Categry_ID = Category_ID连接。



但是,如果我选择Binding for Selected Value Bind(Subcategory_ID),那么我会收到错误(没有绑定过滤工作完美)。



我需要能够选择类别和子类别以及两个选项进入数据库。

我使用的是Visual Studio 2012 vb.net和直接访问SQLDataSource的下拉菜单



如果有人对如何使其工作有任何解决方案或建议,我将不胜感激

谢谢



这是错误:



数据绑定方法,如Eval(),XPath()和Bind()只能在数据绑定控件的上下文中使用。

描述:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中的起源的更多信息。



异常详细信息:System.InvalidOperationException:数据绑定方法,如Eval(), XPath()和Bind()只能在数据绑定控件的上下文中使用。



源错误:



第101行:< br />

第102行:子类别_ID:

第103行:< asp:DropDownList ID =" DropDownListSubcategory" RUNAT = QUOT;服务器"的DataSourceID = QUOT; SqlDataSource_Subcategory" DataTextField = QUOT;子类别" DataValueField = QUOT; Subcategory_ID"高度= QUOT; 46px"宽度= QUOT; 212px"的AutoPostBack = QUOT;真" SelectedValue ='<%#Bind(" Subcategory_ID")%>'>

第104行:< / asp:DropDownList>

第105行:< ; asp:SqlDataSource ID =" SqlDataSource_Subcategory" RUNAT = QUOT;服务器" ConnectionString ="<%$ ConnectionStrings:GARNETConnectionString%>" SelectCommand =" SELECT * FROM [SubCategory_TB] WHERE([Category_ID] = @Category_ID)ORDER BY [SubCategory]">

>Master details dropdown error with data binding after filtration (Category / Subcategory)
I need help with fixing the problem. Both dropdowns lists are part of FormView and part of the "InsertItemTemplet". The first one selects Category (I checked the autopostback) the second dropdown Subcategory filters only records that are matching per categoryID. The dropdown Subcategory is taking data from table (Subcategory_ID, Subcategory, Category_ID)
They are connected via Control Category Dropdown List "Where Categry_ID = Category_ID".

But if I select Binding for Selected Value Bind("Subcategory_ID") then I get error (without binding the filtration works perfect).

I need to be able to select category and subcategory and both selections to enter the database.
I am using Visual studio 2012 vb.net and dropdowns directly accessing SQLDataSource

I would appreciate If anyone has any solution or suggestion on how to make it work
Thanks

Here is the error:

Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

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

Source Error:

Line 101: <br />
Line 102: Subcategory_ID:
Line 103: <asp:DropDownList ID="DropDownListSubcategory" runat="server" DataSourceID="SqlDataSource_Subcategory" DataTextField="SubCategory" DataValueField="Subcategory_ID" Height="46px" Width="212px" AutoPostBack="True" SelectedValue='<%# Bind("Subcategory_ID") %>'>
Line 104: </asp:DropDownList>
Line 105: <asp:SqlDataSource ID="SqlDataSource_Subcategory" runat="server" ConnectionString="<%$ ConnectionStrings:GARNETConnectionString %>" SelectCommand="SELECT * FROM [SubCategory_TB] WHERE ([Category_ID] = @Category_ID) ORDER BY [SubCategory]">

推荐答案

ConnectionStrings:GARNETConnectionString%> ;" SelectCommand =" SELECT * FROM [SubCategory_TB] WHERE([Category_ID] = @Category_ID)ORDER BY [SubCategory]">
ConnectionStrings:GARNETConnectionString %>" SelectCommand="SELECT * FROM [SubCategory_TB] WHERE ([Category_ID] = @Category_ID) ORDER BY [SubCategory]">


这篇关于过滤后数据绑定的主要详细信息下拉错误(类别/子类别)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆