using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

 

using Utilities;

 

namespace Repeater

{

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

    {

        protected void Page_Load(object sender, EventArgs e)

        {

            if (!IsPostBack)

            {

                DBConnect objDB = new DBConnect();

                String strSQL = "SELECT * FROM Product";

 

                // Set the datasource of the Repeater and bind the data

                rptProducts.DataSource = objDB.GetDataSet(strSQL);

                rptProducts.DataBind();

            }

        }

 

        protected void rptProducts_ItemCommand(Object sender, System.Web.UI.WebControls.RepeaterCommandEventArgs e)

        {

            // Retrieve the row index for the item that fired the ItemCommand event

            int rowIndex = e.Item.ItemIndex;

 

            // Retrieve a value from a control in the Repeater's Items collection

            Label myLabel = (Label)rptProducts.Items[rowIndex].FindControl("lblProductID");

            String productNumber = myLabel.Text;

 

            lblDisplay.Text = "You selected ProductNumber " + productNumber;

        }

    }

}