Click here to Skip to main content
15,894,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all.

i stored the image into my database as binary but now i am failing to display it on a grid view.

this is my GridView
C#
<asp:GridView ID="GridView1" runat="server" CellPadding="4"
                      AutoGenerateColumns="False" OnRowEditing="EditRow" OnRowCancelingEdit="CancelEditRow" OnRowUpdating="UpdateRow"
                      DataKeyNames="Party_Number" OnRowDeleting="DeleteRow" AllowPaging="True" PageSize="5" OnPageIndexChanging="ChangePage" BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px">
        <Columns>

     <asp:TemplateField HeaderText="Party Logo">

                              <ItemTemplate>
                                  <%# Eval("Party_Logo") %>
                                  <asp:Image ID="Image1" runat="server" Height="40px" ImageUrl='<%# Bind("Party_Logo") %>' Width="86px" />
                              </ItemTemplate>

                          </asp:TemplateField>
                      </Columns>

                  </asp:GridView>


This is my method to populate the data from the database to the gridview which is working perfectly
C#
public void PopulateData()
   {
       DataTable table = new DataTable();
       using (SqlConnection conn = new SqlConnection(ConnString))
       {
           string sql = "SELECT Party_Logo FROM PARTY";
           using (SqlCommand cmd = new SqlCommand(sql, conn))
           {
               using (SqlDataAdapter ad = new SqlDataAdapter(cmd))
               {
                   ad.Fill(table);
               }
           }
       }
       GridView1.DataSource = table;
       GridView1.DataBind();

   }

when i debug the code , it just display this message System.Byte[]on the box that there should be the image


Please help!!! Please
Posted
Comments
[no name] 10-Jun-13 17:52pm    
Try using generic http handler...

1 solution

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