我的C#代码
public partial class Message : System.Web.UI.Page
{
String strconn = ConfigurationManager.ConnectionStrings["db"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
members();
}
public void members()
{
SqlConnection con = new SqlConnection(strconn);
con.Open();
try
{
string str = "Select Users.Username,Users.Name,ProfilePic.Pathh From Users FULL OUTER JOIN ProfilePic ON Users.username = ProfilePic.Username ORDER BY Users.Sno";
SqlCommand cmd = new SqlCommand(str,con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
repMembers.DataSource = ds;
repMembers.DataBind();
GridView1.DataSource = ds;
GridView1.DataBind();
cmd.Dispose();
con.Close();
}
catch(Exception ex) {
lbMembers.Text = ex.ToString();
}
}
}
我的HTML代码
<asp:Repeater ID="repMembers" runat="server" >
<asp:ItemTemplate >
<div style="width:100%; border-bottom:#ffffff 2px solid;"> <asp:Image ID="Image4" runat="server" ImageUrl='<%#Eval("Pathh") %>' width="60px" Height="60px"/> <asp:Label ID="lb" runat="server" Text='<%#Eval("Username") %>'></asp:Label><br/><asp:Label ID="lbname" runat="server" Text='<%#Eval("Name") %>'></asp:Label><br/></div>
</asp:ItemTemplate>
</asp:Repeater>
我的表格绝对正确并且正在运行,我使用网格视图进行了检查。它给了我“存储的名称”,“用户名”和“路径”。 我用SQL查询检查了它并在网格视图中显示它。
This is the Photo of my table,it is the combination of two tables
答案 0 :(得分:1)
使用ItemTemplate
代替asp:ItemTemplate
。还有一个拼写错误的单词&#34; Pathh&#34;,这会解决您的问题吗?
<ItemTemplate >
<div style="width:100%; border-bottom:#ffffff 2px solid;">
<asp:Image ID="Image4" runat="server" ImageUrl='<%#Eval("Path") %>' width="60px" Height="60px"/>
<asp:Label ID="lb" runat="server" Text='<%#Eval("Username") %>'></asp:Label>
<br/>
<asp:Label ID="lbname" runat="server" Text='<%#Eval("Name") %>'></asp:Label>
<br/>
</div>
</ItemTemplate>