我需要在用户图片旁边显示用户名。图片效果很好,但是 IMGUserLabel 说它不在上下文中。. 你能帮我解决这个问题吗?
public void GetUserDetails(int id)
{
string getUserDetail = "Select ID,Email,Name,Country,Convert(varchar (20), RegisterDate, 106) RegisterDate,Convert(varchar (20), LastLogin, 106) LastLogin ,Description,ImageName FROM [User] where Id='" + id + "'";
dt = dbClass.ConnectDataBaseReturnDT(getUserDetail);
if (dt.Rows.Count > 0)
{
IMGUserLabel.Text = dt.Rows[0]["Name"].ToString();
NameLabel.Text = dt.Rows[0]["Name"].ToString();
UserImage.ImageUrl = "~/UserImage/" + dt.Rows[0]["ImageName"].ToString();
lblCreated.Text = dt.Rows[0]["RegisterDate"].ToString();
LabelLastLogin.Text = dt.Rows[0]["LastLogin"].ToString();
lblCreated.Text = dt.Rows[0]["RegisterDate"].ToString();
LabelAboutMe.Text = dt.Rows[0]["Description"].ToString();
}
}
////////////.aspx //////////
<a href="<%#GetUserDetails(GetUser(Int Id)%>">
<asp:Label ID="IMGUserLabel" runat="server" Text="Label" Font-Names="Segoe UI"
Font-Size="Larger" ForeColor="White"
src="<%#GetUserDetails(GetUser(Int Id)%>">
</asp:Label>
</a>
他的名字“IMGUserLabel”在当前上下文中不存在?