Click here to Skip to main content
15,915,032 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am able to display columns of tables in datalist dynamically in the following code.
However I am unable to display the 'image' column (binary format)named as 'picture_file'
in the same dtalist1. Can anyone help me out?

<form id="form1" runat="server">


<asp:DataList ID="Datalist1" runat="server" DataKeyField="item_code" RepeatDirection="Horizontal"
RepeatLayout="Table">
<HeaderTemplate>
</HeaderTemplate>
<itemtemplate>
Item code:
<asp:Label Id="Itmcodelbl" runat="server" Text='<%#Eval("item_code") %>'>



Item Name:
<asp:Label Id="Itmnamelbl" runat="server" Text='<%#Eval("item_name") %>'>



Particulars:


<asp:TextBox Id="TB1" runat="server" Text='<%#Eval("item_desc") %>'
Height="94" ReadOnly="true" TextMode="MultiLine" BorderStyle="None">



<asp:Image ID="img" runat="server"
ImageUrl='<%#"~/Picture_file.aspx?Id="+Eval("item_code") %>'
style="border:1px solid gray;" Height="136px" Width="158px" />






C#
List<string> adds7 = new List<string>(); //
       SqlDataAdapter da7 = new SqlDataAdapter("SELECT item_code,item_name,item_desc,picture_file FROM item", con);
       SqlCommandBuilder cb7 = new SqlCommandBuilder(da7);
       DataSet ds7 = new DataSet("member");
       da7.Fill(ds7, "member");
       for
           (
           int i = 0; i < ds7.Tables[0].Rows.Count; i++)
       {
           adds7.Add(ds7.Tables[0].Rows[i].ItemArray[0].ToString());
       }
       Datalist1.DataSource = ds7.Tables[0];
       Datalist1.DataBind();
       Datalist1.Visible = true;
Posted
Updated 20-Sep-13 21:33pm
v4
Comments
S.Rajendran from Coimbatore 21-Sep-13 3:50am    
I get the icon but not the real image

1 solution

You can try out the below link


[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900