TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rajveer Singh
NA
74
8.1k
how to display image in datalist aspnet c#
Oct 13 2015 6:24 AM
Pet.aspx
<p>
<asp:DataList ID="DataList6" runat="server" CellPadding="4" ForeColor="#333333" RepeatColumns="5" RepeatDirection="Horizontal">
<AlternatingItemStyle BackColor="White" />
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" HorizontalAlign="Center" VerticalAlign="Middle"/>
<HeaderTemplate>Sheep Details</HeaderTemplate>
<ItemStyle BackColor="#E3EAEB" />
<ItemTemplate>
<asp:Image ID="imgEmp" runat="server" Width="100px" Height="120px" ImageUrl='<%# Bind("Picture", "petpic/") %>' style="padding-left:40px"/><br />
<br />
Breed:
<asp:Label ID="BreedLabel" runat="server" Text='<%# Eval("Breed") %>' />
<br />
Name:
<asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
<br />
Age:
<asp:Label ID="AgeLabel" runat="server" Text='<%# Eval("Age") %>' />
<br />
Gender:
<asp:Label ID="GenderLabel" runat="server" Text='<%# Eval("Gender") %>' />
<br />
Weight:
<asp:Label ID="WeightLabel" runat="server" Text='<%# Eval("Weight") %>' />
<br />
Date:
<asp:Label ID="DateLabel" runat="server" Text='<%# Eval("Date") %>' />
<br />
</ItemTemplate>
<SelectedItemStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
</asp:DataList>
</p>
Pet.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
con.Open();
if (!IsPostBack)
{
BindData5();
}
}
protected void BindData5()
{
DataSet ds = new DataSet();
string cmdstr = "Select top 6 * from Sheep";
SqlCommand cmd = new SqlCommand(cmdstr, con);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
adp.Fill(ds);
DataList6.DataSource = ds.Tables[0];
DataList6.DataBind();
}
Above is the codes.. so i have a folder in my project called "petpic"
when i insert picture to database it goes into that folder..
but it doesnt show on the datalist.. what is wrong.. help me
Reply
Answers (
9
)
Frozen with Pagination
How to calculate difference of two dates in numeric values