我正在选择当前用户的表格数据:
SELECT [ConfidenceLevel], [LoveLevel], [HappinessLevel] FROM [UserData] WHERE ([UserProfileID] = @UserProfileID)
我已将控件设置为唯一的用户ID,并且它获得了正确的值:
HTML: <asp:Label ID="userID" runat="server" Text="Labeluser"></asp:Label>
C#: userID.Text = Membership.GetUser().ProviderUserKey.ToString();
然后我使用Configure Data Source窗口在where子句中使用它 唯一ID =控制然后controlID userID (填写.text给我)
我编译并运行但没有显示表应该在哪里。有什么建议?
以下是它创建的代码:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="ConfidenceLevel" HeaderText="ConfidenceLevel"
SortExpression="ConfidenceLevel" />
<asp:BoundField DataField="LoveLevel" HeaderText="LoveLevel"
SortExpression="LoveLevel" />
<asp:BoundField DataField="HappinessLevel" HeaderText="HappinessLevel"
SortExpression="HappinessLevel" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionStringToDB %>"
SelectCommand="SELECT [ConfidenceLevel], [LoveLevel], [HappinessLevel] FROM [UserData] WHERE ([UserProfileID] = @UserProfileID)">
<SelectParameters>
<asp:ControlParameter ControlID="userID" Name="UserProfileID"
PropertyName="Text" Type="Object" />
</SelectParameters>
</asp:SqlDataSource>
答案 0 :(得分:2)
我已经在asp.net页面上回答了,但如果你没看到那个我也会在这里做...
取出对sqldatasource代码生成的“对象”的任何引用......
应该是:
PropertyName =“Text”/&gt;
如果你有更新并插入和删除,你也必须从那里删除它......