我有这个sql命令:
SELECT Jmeno,
COUNT(CASE WHEN Ucast = 'TRUE' then 1 end) as Pocet_zapasu,
SUM(CASE WHEN Branky>=0 then Branky end) as branek
FROM Hraci
INNER JOIN Ucast_Zapas ON Ucast_Zapas.ID_Hrace_zapas=Hraci.IDHrace
INNER JOIN Zapas ON Zapas.ID_zapas=Ucast_Zapas.ID_zapasu_ucast
INNER JOIN Kategorie ON Kategorie.IDkategorie=Zapas.Kategorie_zapas
WHERE (Zapas.Druh=1) GROUP BY Jmeno
但是当我在listview中使用这个命令时:
<asp:ImageButton ID="Image2" runat="server" ImageUrl="~/Icons/edit.png" PostBackUrl='<%#string.Format("/Default3.aspx?id={0}",Eval("IDHrace"))%>' />
我有这个错误:
DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'IDHrace'.
因为在sqlcommand中缺少Hraci.IDHrace ...但我不知道为什么我将Hraci.IDHrace提供给以前的sqlcommand .. 你知道吗?
答案 0 :(得分:2)
您的查询未返回IDHrace
。
您应该将其包含在SELECT
声明中:
SELECT
Hraci.IDHrace,
Jmeno,
COUNT(CASE WHEN Ucast = 'TRUE' then 1 end) as Pocet_zapasu,
SUM(CASE WHEN Branky>=0 then Branky end) as branek
FROM Hraci
INNER JOIN Ucast_Zapas ON Ucast_Zapas.ID_Hrace_zapas=Hraci.IDHrace
INNER JOIN Zapas ON Zapas.ID_zapas=Ucast_Zapas.ID_zapasu_ucast
INNER JOIN Kategorie ON Kategorie.IDkategorie=Zapas.Kategorie_zapas
WHERE (Zapas.Druh=1) GROUP BY Jmeno, Hraci.IDHRace
答案 1 :(得分:0)
您需要在sql语句中选择IDHrace