Click here to Skip to main content
15,667,847 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello... my question is how to display image in image control and display details in gridview by using join two tables in and C#??

i have two tables which are barcode printer detail and image. i use join tables to display details and image. But i just can display image without details. Is it possible to display image in control? Below is my code:
SqlDataAdapter SDA = new SqlDataAdapter("SELECT B.Product,B.Model,B.SerialNo,B.IT_Tag,B.PrinterID,B.Department,B.Location,L.Image FROM BarCodePrinter B JOIN Layout L ON L.Department=B.Department AND L.Location=B.Location WHERE B.SerialNo=@SN OR B.IT_Tag=@Tag OR B.PrinterID=@PrinterID", con);                 
                    SDA.SelectCommand.Parameters.AddWithValue("@SN", TextBox1.Text);
                    SDA.SelectCommand.Parameters.AddWithValue("@Tag", TextBox1.Text);
                    SDA.SelectCommand.Parameters.AddWithValue("@PrinterID", TextBox1.Text);
                    DataSet ds = new DataSet();
                    DataTable dt = new DataTable();
                    //match with database
                    if (dt.Rows.Count > 0)
                        GridView3.DataSource = dt;
                       Byte[] bytes = (Byte[])dt.Rows[0]["Image"];

Please help me!!! thanks.
Updated 3-Jan-13 14:43pm

1 solution

you can use Eval() method in aspx page for display detail.

Example : -
<asp:GridView ID="GridView1" runat="server">
                    <asp:Label ID="lblmodel" runat="server" Text='<%# Eval("Model") %>'></asp:Label>
                    <asp:Label ID="lblIT_Tag" runat="server" Text='<%# Eval("IT_Tag") %>'></asp:Label>

Share this answer
WinnieMeeKun 3-Jan-13 19:50pm    
Hello..thanks for ur solution..but the Gridview3 is for display the details...but when run system, the details missing and only image display...y???
Rakesh Tailor 4-Jan-13 2:46am    
hello... can you display your database table..?
WinnieMeeKun 6-Jan-13 22:07pm    
hello!!! display database table??? i have two, i join the two tables to retrieve image and details...
Rakesh Tailor 4-Jan-13 3:07am    
hello.... once comment to

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