I’m trying to display an avatar of user that wrote a comment. I’m using listview to display “comment, date, username and imageAvatar”, but can’t figure out what a problem..
<asp:Image ID="DisplayAvatarShout"
runat="server"
AlternateText='<%# Eval ("UserName") %>'
ImageUrl='~/images/user_images/<%# Eval ("Avatar") %>'
width="20px" />
<img src='~/images/user_images/<%# Eval ("Avatar") %>'
width="20px"
alt='<%# Eval ("UserName") %>' />
Here is Sql connection, maybe there is a problem
SelectCommand="SELECT aspnet_Users.UserName, Custon_Shouts.Body_shout, Custon_Shouts.Date_shout, Custon_UserInfo.Avatar FROM aspnet_Users INNER JOIN Custon_Shouts ON aspnet_Users.UserId = Custon_Shouts.UserId INNER JOIN Custon_UserInfo ON aspnet_Users.UserId = Custon_UserInfo.UserId ORDER BY Custon_Shouts.Date_shout DESC">
</asp:SqlDataSource>
Rendered HTML
<img id="ContentPlaceHolder1_ListView3_DisplayAvatarShout_1" src="images/user_images/%3C%25#%20Eval%20(%22Avatar%22)%20%25%3E" alt="rokky" style="width:20px;" /> <img src='~/images/user_images/022.jpg' width="20px" alt='rokky' />
Assuming that your images specified in the
Avatarcolumn actually exist at the path on the server, and there is a resultset with valid data coming back in your SqlDataSource, then you should be able to write: