您好我正在尝试使用具有查询字符串值的参数创建一个 SQLDataSource,但我不断收到一条错误消息:
PropertyName 必须设置为 ControlParameter 'SubcategoryId' 中名为 'ListOfPosts' 的控件的有效属性名称
我似乎无法理解 propertyName 应该是什么。这是我的代码:
<asp:SqlDataSource ID="ListOfPosts" runat="server"
ConnectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True"
ProviderName="System.Data.SqlClient"
SelectCommand="SELECT [forum_posts].[PostTitle], [forum_posts].[PostContent], [forum_posts].[PostDate],
aspnet_Users.Username , forum_subcategories.SubCategoryName
FROM [forum_posts]
JOIN aspnet_Users ON [forum_posts].UserId = aspnet_Users.UserId
JOIN forum_subcategories on forum_posts.SubcategoryId = forum_subcategories.SubCategoryID
WHERE [forum_posts].SubcategoryId = @SubcategoryId">
<SelectParameters>
<asp:ControlParameter Name="SubcategoryId" ControlID="ListOfPosts" Type="String" DefaultValue='<%= Request.QueryString["post"] %>'/>
</SelectParameters>
</asp:SqlDataSource>