我有我的網頁上顯示學生姓名和圖像,而從下拉列表中選擇學生證。該圖像以db的二進制格式存儲。我如何檢索圖像並在圖像框中顯示。下面給出的代碼僅顯示學生的名字和姓氏。我如何顯示圖像?請幫幫我。如何將二進制圖像顯示到圖像框?
代碼:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DataSet1TableAdapters.TextBoxTableTableAdapter tx;
tx = new DataSet1TableAdapters.TextBoxTableTableAdapter();
DataTable dt = new DataTable();
dt = tx.GetstudData(int.Parse(DropDownList1.SelectedValue));
foreach (DataRow row in dt.Rows)
{
TextBox1.Text = (row["FirstName"].ToString());
TextBox2.Text = (row["SecondName"].ToString());
}
}
SQL查詢:
SELECT FirstName, SecondName, StudentImage FROM TextBoxTable WHERE (Id = @Id)
.aspx的來源:
<div>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Image ID="Image1" runat="server" />
</div>
數據庫:
我不想使用通用HTTP處理程序。我想在我的網頁上顯示圖像而不使用通用的http處理程序。 – Vipin 2014-10-16 13:35:30