如何在图像控件中显示图像并使用asp.net中的连接两个表格在gridview中显示细节? [英] How to display image in image control and display details in gridview by using join two tables in asp.net?
本文介绍了如何在图像控件中显示图像并使用asp.net中的连接两个表格在gridview中显示细节?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好...我的问题是如何在图像控件中显示图像并在grid.net中使用asp.net和C#中的连接两个表来显示详细信息???
i有两个表,它们是条形码打印机的细节和图像。我使用连接表来显示细节和图像。但我只是可以显示没有细节的图像。是否可以在控制中显示图像?下面是我的代码:
Hello... my question is how to display image in image control and display details in gridview by using join two tables in asp.net 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();
SDA.Fill(dt);
//match with database
if (dt.Rows.Count > 0)
{
GridView3.DataSource = dt;
GridView3.DataBind();
GridView3.Focus();
Byte[] bytes = (Byte[])dt.Rows[0]["Image"];
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
}
请帮帮我!!!谢谢。
Please help me!!! thanks.
推荐答案
您可以在aspx页面中使用Eval()方法来显示详细信息。
示例: -
you can use Eval() method in aspx page for display detail.
Example : -
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lblmodel" runat="server" Text='<%# Eval("Model") %>'></asp:Label>
<asp:Label ID="lblIT_Tag" runat="server" Text='<%# Eval("IT_Tag") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
回复
reply
这篇关于如何在图像控件中显示图像并使用asp.net中的连接两个表格在gridview中显示细节?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文