问题描述
本人想做一个类似于QQ空间显示评论的功能,外层是所有的上传的照片动态,每个照片下面有个datalist显示该心情二部分评论!出错了,麻烦大侠指点一下!错误提示:当前上下文中不存在名称“photoid”源错误:行49:</ItemTemplate>行50:</asp:DataList>行51:<asp:SqlDataSourceID="SqlDataSource3"runat="server"行52:SelectCommand='<%#"SELECTTOP(4)comment.[content],comment.commentdata,comment.usernumber,userinfo.username,userinfo.pictureFROMcommentINNERJOINuserinfoONcomment.usernumber=userinfo.usernumberWHERE(comment.photoid="+Eval(photoid)+")ORDERBYcomment.commentdataDESC"%>'行53:ConnectionString="<%$ConnectionStrings:ConnectionString2%>">代码:<asp:DataListID="DataList1"runat="server"DataSourceID="SqlDataSource2"><ItemTemplate><tablestyle="width:596px;max-height:50px"><trstyle="width:596px;max-height:80px"valign="top"><tdstyle="width:50px"><ahref="home_pre.aspx?usernumber=<%#Eval("usernumber")%>&&photoid=<%#Eval("photoid")%>"><asp:ImageID="Image4"runat="server"Height="60px"Width="50px"ImageUrl='<%#Eval("picture")%>'ImageAlign="Middle"/></a></td><tdstyle="height:50px;width=56px"align="left"><ahref="home_pre.aspx?usernumber=<%#Eval("usernumber")%>"><asp:LabelID="yonghu3"runat="server"Text='<%#Eval("username")%>'ForeColor="#0099FF"></asp:Label>上传照片到:</a><asp:LabelID="xiangcemingcheng"runat="server"Text='<%#Eval("phototitle")%>'></asp:Label> <divstyle="text-align:center"><asp:ImageID="Image6"runat="server"ImageUrl='<%#Eval("url")%>'ImageAlign="Middle"/></div><asp:LabelID="photoid"runat="server"Text='<%#Eval("photoid")%>'Visible="false"></asp:Label></td></tr><tr><tdstyle="width:50px;height:16px"></td><td><asp:DataListID="DataList_xcpl"runat="server"DataSourceID="SqlDataSource3"><ItemTemplate><tablestyle="width:536px;max-height:50px;text-align:right"><trstyle="width:536px;max-height:80px;text-align:left"valign="top"><tdstyle="width:30px;text-align:left"valign="top"><ahref='home_pre.aspx?usernumber=<%#Eval("usernumber")%>'><asp:ImageID="Image3"runat="server"Height="36px"Width="30px"ImageUrl='<%#Eval("picture")%>'ImageAlign="Middle"/></a></td><tdstyle="height:50px;max-height:506px;"align="left"><ahref='home_pre.aspx?usernumber=<%#Eval("usernumber")%>'><asp:LabelID="Label6"runat="server"Text='<%#Eval("username")%>'ForeColor="#0099FF"></asp:Label>评论说:</a><asp:LabelID="Label7"runat="server"Text='<%#Eval("content")%>'></asp:Label> <asp:LabelID="Label9"runat="server"Text='<%#Eval("commentdata")%>'ForeColor="Gray"></asp:Label></td></tr></table></ItemTemplate></asp:DataList><asp:SqlDataSourceID="SqlDataSource3"runat="server"SelectCommand='<%#"SELECTTOP(4)comment.photoid,comment.[content],comment.commentdata,comment.usernumber,userinfo.username,userinfo.pictureFROMcommentINNERJOINuserinfoONcomment.usernumber=userinfo.usernumberWHERE(comment.photoid="+Eval(photoid)+")ORDERBYcomment.commentdataDESC"%>'ConnectionString="<%$ConnectionStrings:ConnectionString2%>"></asp:SqlDataSource></td></tr></table></ItemTemplate></asp:DataList><asp:SqlDataSourceID="SqlDataSource2"runat="server"SelectCommand="SELECTTOP(4)userinfo.username,userinfo.picture,photo.photoid,photo.url,photo.photodataFROMuserinfoINNERJOINphotoONuserinfo.usernumber=photo.usernumber"ConnectionString="<%$ConnectionStrings:ConnectionString2%>"></asp:SqlDataSource>
解决方案
解决方案二:
SelectCommand='<%#"SELECTTOP(4)comment.[content],comment.commentdata,comment.usernumber,userinfo.username,userinfo.pictureFROMcommentINNERJOINuserinfoONcomment.usernumber=userinfo.usernumberWHERE(comment.photoid="+Eval(photoid)+")ORDERBYcomment.commentdataDESC"%>'------》SelectCommand='<%#"SELECTTOP(4)comment.[content],comment.commentdata,comment.usernumber,userinfo.username,userinfo.pictureFROMcommentINNERJOINuserinfoONcomment.usernumber=userinfo.usernumberWHERE(comment.photoid="+Eval("photoid")+")ORDERBYcomment.commentdataDESC"%>'-------------------------------这里这么长建议后来写个带object参数的方法,比如:GetStr前台<%#GetString(Eval("字段"))%>
解决方案三:
不行啊~~~<'附近有语法错误。以'SELECTTOP(4)comment.photoid,comment.[content],comment.commentdata,userinfo.username,userinfo.pictureFROMcommentINNERJ'开头的标识符太长。最大长度为128。