How to display default from folder if user did not upload any image, i have imagename in database and image in folder called userimages, then i have a default image folder called missingimages. if user didnt upload profile image the code will then move over to the next code and display default image. i have littel code on this below but need more help on it.
public string getHREF(object sURL)
{
DataRowView dRView = (DataRowView)sURL;
string Id = dRView["Id"].ToString();
return ResolveUrl("~/Pages/Timeline.aspx?Id=" + Id);
}
public string getSRC(object imgSRC)
{
DataRowView dRView = (DataRowView)imgSRC;
DataRowView eRView = (DataRowView)imgSRC;
string ImageName = dRView["ImageName"].ToString();
string Name = dt.Rows[0]["Name"].ToString();
if (ImageName == "NoImage")
{
return ResolveUrl(@"~/UserImage/missing.jpg");
}
else
{
return ResolveUrl("~/UserImage/" + dRView["ImageName"].ToString());
}
}
HTML
<asp:DataList ID="SUGGESTEDAD" runat="server" Width="100%" RepeatDirection="Horizontal"
CellPadding="2" CellSpacing="2">
<ItemTemplate>
<div class="">
<div class="box box-default box-solid direct-chat direct-chat-default " style="height: auto;
width: 250px; margin-left: 4px; margin-right: 4px">
<div class="box-header" style="background-color: transparent">
<div class="clearfix">
</div>
<div class="box-tools ">
<button class="btn btn-box-tool" data-widget="remove">
<i class="fa fa-times"></i>
</button>
</div>
</div>
<!-- /.box-header -->
<div class="box-body">
<!-- Conversations are loaded here -->
<div class="">
<!-- Message. Default to the left -->
<div class="col-sm-12 ">
<a href='<%#getHREF(Container.DataItem)%>'>
<input type="hidden" id="hiddenId" value='<%# DataBinder.Eval(Container.DataItem, "FromId") %>'
runat="server" name="hiddenId" />
<img src='<%# getSRC(Container.DataItem) %>' class="img-responsive img-circle img-thumbnail animated bounceIn"
alt="User Image" style="">
<asp:Label ID="lblName" runat="server"></asp:Label>
<asp:Label ID="Label2" runat="server" CssClass="redtext"></asp:Label>
</a> </div>
</div>
</div>
<div class="clearfix">
</div>
<div class="box-footer" style="margin-left: 4px; margin-right: 4px; margin-bottom: 6px;
margin-top: 6px; height: 40px">
<a href='<%#getHREF(Container.DataItem)%>'> <i class="fa fa-arrow-right">
<asp:Label ID="Name" runat="server" Text='<%# Eval("Name") %>' /></i> </a>
</div>
</div>
</div>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:DataList>