“System.Web.UI.WebControls.Repeater”不包含名称为“SelectedValue”的属性

发布于 2024-12-13 03:21:36 字数 826 浏览 0 评论 0原文

我不确定我应该在 vb.net 项目后面的代码中编写什么。我有一个过滤网格视图的中继器。当尝试声明标量变量 @CompanyID 时,我收到了本文标题中提到的错误。有人可以帮助我吗?我尝试在许多论坛上寻找答案,但找不到正确的答案。

dsLetters.SelectCommand = "SELECT DISTINCT LEFT(ProductName, 1) AS [Letter] 
                          FROM Product, CompanyLink, Company 
                          WHERE Product.ProductID = CompanyLink.ProductID 
                          AND CompanyLink.CompanyID = Company.CompanyID 
                          AND Company.CompanyID = @CompanyID"

    'declaring scalar variable @CompanyID
    dsLetters.SelectParameters.Clear()
    Dim cp As ControlParameter = New ControlParameter
    cp.ControlID = "rptLetters"
    cp.DefaultValue = "-1"
    cp.Name = "CompanyID"
    cp.PropertyName = "SelectedValue"
    cp.Type = TypeCode.Decimal
    dsLetters.SelectParameters.Add(cp)

I am not sure what I am supposed to write in the code behind for my vb.net project. I have a repeater that filters a gridview. When trying to declare the scalar variable @CompanyID, I get the error I mentioned in the title of this post. Can someone help me? I have tried to look for the answer on many forums, but I can't find the right answer.

dsLetters.SelectCommand = "SELECT DISTINCT LEFT(ProductName, 1) AS [Letter] 
                          FROM Product, CompanyLink, Company 
                          WHERE Product.ProductID = CompanyLink.ProductID 
                          AND CompanyLink.CompanyID = Company.CompanyID 
                          AND Company.CompanyID = @CompanyID"

    'declaring scalar variable @CompanyID
    dsLetters.SelectParameters.Clear()
    Dim cp As ControlParameter = New ControlParameter
    cp.ControlID = "rptLetters"
    cp.DefaultValue = "-1"
    cp.Name = "CompanyID"
    cp.PropertyName = "SelectedValue"
    cp.Type = TypeCode.Decimal
    dsLetters.SelectParameters.Add(cp)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

难理解 2024-12-20 03:21:36

我认为问题在于中继器没有选定值的概念;他们所做的只是显示您所选择的内容。您可能需要做的是模仿隐藏下拉列表中的转发器值,并添加客户端代码以在下拉列表中选择适当的值,然后将 ControlParameter 绑定到此属性。

I think the issue is that repeaters don't have the concept of a selected value; all they do is show what you have selected. What you may need to do is mimic the repeater values in a hidden dropdownlist and add client-side code to choose the appropriate value in the dropdownlist, then bind your ControlParameter to this property.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文