using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using
Utilities;
using System.Data;
namespace
Database
{
public partial class ProductViewer : System.Web.UI.Page
{
DBConnect objDB = new DBConnect();
string strSQL;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
strSQL = "SELECT
DepartmentName, DepartmentNumber
FROM Department ORDER BY DepartmentNumber";
ddlDepartments.DataSource
= objDB.GetDataSet(strSQL);
ddlDepartments.DataTextField
= "DepartmentName";
ddlDepartments.DataValueField
= "DepartmentNumber";
ddlDepartments.DataBind();
}
else
{
DataSet ds;
strSQL = "SELECT
ProductNumber, Description FROM Product WHERE DepartmentNumber = " +
ddlDepartments.SelectedValue +
" ORDER BY Description";
ds = objDB.GetDataSet(strSQL);
//
Before binding the Dataset to GridView,
//
add a Column to the dataset for the image file & store the image from
database using a handler.
//
The column/field name "imgFile"
is already databound to the ImageField
column in the GridView
//
using the properties (see ASPX Markup).
ds.Tables[0].Columns.Add("imgFile");
//
Go through each row in the dataset and store a URL value in the imgFile field that
//
will be used to process and display the image from the database in the ImageField.
foreach (DataRow tempRow in ds.Tables[0].Rows)
{
tempRow["imgFile"] = "ImageGrab.aspx?ID=" + tempRow["ProductNumber"];
}
gvProducts.DataSource
= ds;
gvProducts.DataBind();
}
}
protected void ddlDepartments_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}