0
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:arqsi43ConnectionString %>" SelectCommand="SELECT [nome], [votos], [id] FROM [Playlist] WHERE ([semana_votacao] = @semana_votacao)">
   <SelectParameters>
       <asp:QueryStringParameter Name="semana_votacao" 
                QueryStringField="SELECT MAX(id) FROM VotacaoSemana" Type="Int32" />
   </SelectParameters>
</asp:SqlDataSource>

我有 2 张桌子 -PlayListVotacaoSemana.

我需要在 gridview 上显示PlayList其属性semana_votacao等于 table 中的 max id 的所有值votacaosemana

我使用向导尝试配置它,但我做错了,因为gridview是空的......

有什么帮助吗?

4

1 回答 1

1

您不能为QueryStringFieldis编写 sql 查询url query string。改变你SelectCommand如下和no need to have parameters

SelectCommand = "SELECT [nome], [votos], [id] FROM [Playlist] 
WHERE [semana_votacao] = (SELECT MAX(id) FROM VotacaoSemana)"
于 2012-12-08T12:58:33.173 回答