select c.id,a.PCName,b.pcname,b.pinyin,b.JianMa,c.location
from cf_provice_city a inner join cf_provice_city b on a.pcid = b.ParentId inner join cf_location c on b.pcid=c.pcid
where b.PCName='苏州市'
在数据库中这行SQL执行是没有问题的,但是如何用Eval绑定到一列中去?我之前是这样绑定的:<asp:Label runat="server" ID="lblCity" Text='<%# Eval("a.PCName")+"-"+Eval("b.pcname")+"("+Eval("b.pinyin")+"-"+Eval("b.JianMa")+")" %>'></asp:Label>但是运行后一直报错,说找不到a。后来我在高人的指导下把SQL改成了select c.id,a.PCName as city,b.pcname asprovince,b.pinyin,b.JianMa,c.location from cf_provice_city a inner join cf_provice_city b on a.pcid = b.ParentId inner join cf_location c on b.pcid=c.pcid where b.PCName='苏州市' 在用Eval绑定就可以了!
<asp:Label runat="server" ID="lblCity" Text='<%# Eval("City")+"-"+Eval("Province")+"("+Eval("pinyin")+"-"+Eval("JianMa")+")" %>'></asp:Label>