using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

 

using Utilities;

 

namespace GridViews

{

    public partial class GridViewExample9 : System.Web.UI.Page

    {

        DBConnect objDB = new DBConnect();

 

        protected void Page_Load(object sender, EventArgs e)

        {

            if (!IsPostBack)

            {

                String strSQL = "SELECT * FROM Product";

               

                // Bind the dataset data to the drop-down list

                // set the text displayed in the list to the Description field value

                // and the value of a selected item to the ProductNumber field value

                ddlProducts.DataSource = objDB.GetDataSet(strSQL);

                ddlProducts.DataTextField = "Description";

                ddlProducts.DataValueField = "ProductNumber";

                ddlProducts.DataBind();

 

            }

        }

 

        public void ShowProducts(String theProductNumber)

        {

            String strSQL = "SELECT * FROM Product WHERE ProductNumber = '" + theProductNumber + "'";

            gvProducts.DataSource = objDB.GetDataSet(strSQL);

            gvProducts.DataBind();

        }

 

        protected void ddlProducts_SelectedIndexChanged(object sender, EventArgs e)

        {

            ShowProducts(ddlProducts.SelectedValue);

        }

 

    }

}