none
HOW TO ACCESS MULTIPLE ROWS FROM GRIDVIEW AND POPULATE THE CORRESPONDING DROP DOWN DATASOURCE SEQUENTIALLY RRS feed

  • Question

  • Aneel Goplani

    B.S.c Computer & Information Science. Minnesota State University, Mankato. USA 2002. Cum Laude.

    Dated: May 7th, 2017.

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Collections.Generic;
    using System.Web;
    using System.Web.Security;
    using System.Linq;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
    using System.Data.SqlClient;
    using System.Text;
    using System.Web.Configuration;
    using System.Globalization;
    using System.Drawing;
    using System.Threading;
    
    namespace ComputerHardwareShopCart
    {
        public partial class ShopCart2 : System.Web.UI.Page
        {
            private int n; private static int PageSize = 4;
          
    
        public string StyleRep
        {
            get;
            set;
        }
        public ShopCart2()
        {
        }
        public ShopCart2(string StyleRep)
        {
           
            this.StyleRep = StyleRep;
        }
            protected void Page_Load(object sender, EventArgs e)
            {
          
                if (!this.IsPostBack)
                {
                    ddlImages.DataSource = GetData("SELECT Design, id FROM LordStock");
                    ddlImages.DataTextField = "Design";
                    ddlImages.DataValueField = "id";
                    ddlImages.DataBind();
    
                  /*  DropDownList ddl1 = null;
                    foreach (GridViewRow row in GridView1.Rows)
                    {
                        ddl1 = (DropDownList)row.FindControl("DropDownList2");
                        ddl1.DataSource = Products2();
                        ddl1.DataTextField = "StyleRep";
                        ddl1.DataValueField = "StyleRep";
                        ddl1.DataBind();
                    }             
               
                   */
                }
                
            }
    
            protected DataTable GetProducts(int categoryID)
            {
    
                string connection = ConfigurationManager.ConnectionStrings["DB_JDBCLOGConnectionString"].ConnectionString;
    
                string commandtext = "SELECT * FROM NestedSuits t1 inner join dbo.tblImages t2 on t2.Firstname=t1.Suit_Style where t2.id =" + categoryID;
                using (SqlConnection conn = new SqlConnection(connection))
                {
                    using (SqlCommand cmds = new SqlCommand(commandtext, conn))
                    {
                        conn.Open();
                        SqlDataAdapter da = new SqlDataAdapter(cmds);
                        DataTable dt = new DataTable();
                        da.Fill(dt);
                        return dt;
                    }
                }
            }
            protected DataTable Products2()
            {
    
                string connection = ConfigurationManager.ConnectionStrings["DB_JDBCLOGConnectionString"].ConnectionString;
                string cell_value_1 = GridView1.Rows[0].Cells[0].Text;
               
                string commandtext = "Select StyleRep FROM dbo.NestedSuits where Suit_Style='Mens Style'";
                using (SqlConnection conn = new SqlConnection(connection))
                {
                    using (SqlCommand cmds = new SqlCommand(commandtext, conn))
                    {
                        conn.Open();
                        SqlDataAdapter da = new SqlDataAdapter(cmds);
                        DataTable dt = new DataTable();
                        da.Fill(dt);
                        return dt;
                    }
                }
            }
    
    
            protected DataTable Products(int categoryID)
            {
                string conn = ConfigurationManager.ConnectionStrings["DB_JDBCLOGConnectionString"].ConnectionString;
                
                string commandtext = "SELECT * FROM tblImages t1 inner join LordStock t2 on t2.Design=t1.StoreSelection where t2.id =" + categoryID;
                SqlConnection conns = null;
                using (conns = new SqlConnection(conn))
                {
                    conns.Open();
                    DataTable dt = new DataTable();
                    SqlDataAdapter ad = new SqlDataAdapter(commandtext, conns);
                    
                    
                    ad.Fill(dt);
    
                    if (dt != null)
                    {
                        if (dt.Rows.Count != 0)
                        {
                            GridView1.DataSource = dt;
                            GridView1.DataBind();
    
                        }
    
                    }
    
                    string cmdtext = "Select StyleRep from dbo.NestedSuits t3 inner join dbo.tblImages t4 on t3.Suit_Style=t4.Firstname inner join dbo.LordStock t2 on t2.Design=t4.StoreSelection where t2.id=" + Session["value"];
    
                    DataTable dts = new DataTable();
    
                    SqlDataAdapter ads = new SqlDataAdapter(cmdtext, conns);
    
                    ads.Fill(dts);
                    if (dts != null)
                    {
                        if (dts.Rows.Count != 0)
                        {
                            SqlCommand cmdsf = null;
                             
                            using (cmdsf = new SqlCommand(cmdtext))
                            {
                                cmdsf.Connection = conns;
                                SqlDataReader reader = null;
                                using (reader = cmdsf.ExecuteReader())
                                {
                                    try
                                    {
                                        if (reader.Read())
                                        {
                                            var i = reader.GetString(reader.GetOrdinal("StyleRep"));
                                            do
                                            {
    
    
                                                foreach (GridViewRow row in GridView1.Rows)
                                                {
                                                    //Finding Dropdown control  
                                                    Control ctrl = row.FindControl("ddl2") as DropDownList;
                                                    if (ctrl != null)
                                                    {
                                                        DropDownList ddl1 = (DropDownList)ctrl;
    
    
                                                        var list = new List<ShopCart2>();
                                                        list.Add(new ShopCart2(i));
                                                        ddl1.DataTextField = "StyleRep";
                                                        ddl1.DataValueField = "StyleRep";
                                                        ddl1.DataSource = list;
                                                        ddl1.DataBind();
    
                                                    }//if closed
                                                }// for closed
    
    
    
                                            } while (reader.Read());
    
    
                                        }
    
                                    }
                                    catch (NullReferenceException ex)
                                    {
                                        ex.GetBaseException();
                                        Console.Write("Exception Caught");
                                    }
                                    catch (ArgumentNullException exf)
                                    {
                                        exf.GetType();
                                        Console.Write("Argument Exception Caught");
                                    }
                                    catch (OverflowException er)
                                    {
                                        er.GetHashCode();
                                    }
                                    catch (StackOverflowException)
                                    {
                                        Console.Write("Stack Overflow Exception");
                                    }
                                    catch (IndexOutOfRangeException)
                                    {
                                        Console.Write("Index Out of Range Error");
                                    }
                                    finally
                                    {
                                        conns.Dispose();
                                        conns.Close();
                                    }
                               }
                          }
                     }
             
                 }
                    return dts;
                }
          }
            
                /*
                string connection = ConfigurationManager.ConnectionStrings["DB_JDBCLOGConnectionString"].ConnectionString;
               
                string commandtext = "SELECT * FROM tblImages t1 inner join LordStock t2 on t2.Design=t1.StoreSelection where t2.id =" + categoryID;
                using (SqlConnection conn = new SqlConnection(connection))
                {
                    using (SqlCommand cmds = new SqlCommand(commandtext,conn))
                    {
                        conn.Open();
                        SqlDataAdapter da = new SqlDataAdapter(cmds);
                        DataTable dt = new DataTable();
                        da.Fill(dt);
                        return dt;
                    }
                }
                 */
                    
    
    
    
            protected void FetchProducts()
            {
    
                string connection = ConfigurationManager.ConnectionStrings["DB_JDBCLOGConnectionString"].ConnectionString;
    
                string commandtext = "Select StyleRep from dbo.NestedSuits t3 inner join dbo.tblImages t4 on t3.Suit_Style=t4.Firstname inner join dbo.LordStock t2 on t2.Design=t4.StoreSelection where t2.id=" + Session["value"];
                using (SqlConnection conn = new SqlConnection(connection))
                {
                    using (SqlCommand cmds = new SqlCommand(commandtext, conn))
                    {
                        cmds.CommandType = CommandType.Text;
                        cmds.Connection = conn;
                        conn.Open();
                        foreach (GridViewRow row in GridView1.Rows)
                        {
                            //Finding Dropdown control  
                            Control ctrl = row.FindControl("ddl2") as DropDownList;
                            if (ctrl != null)
                            {
                                DropDownList ddl1 = (DropDownList)ctrl;
    
                                SqlDataAdapter da = new SqlDataAdapter(cmds);
    
                                DataTable dt = new DataTable();
                                da.Fill(dt);
    
                                ddl1.DataTextField = "StyleRep";
                                ddl1.DataValueField = "StyleRep";
    
                                ddl1.DataSource = dt;
                                ddl1.DataBind();
    
                            }
                        }
                    }
    
                }
            }
            /*
            public String GetData1()
            {
                string connection = ConfigurationManager.ConnectionStrings["DB_JDBCLOGConnectionString"].ConnectionString;
                string tcolumn = "";
                string commandtext = "SELECT Firstname FROM tblImages WHERE StoreSelection =" + ddlImages.SelectedItem.Value;
                using (SqlConnection conn = new SqlConnection(connection))
                {
                    using (SqlCommand cmds = new SqlCommand(commandtext))
                    {
                        conn.Open();
                        tcolumn = (string)cmds.ExecuteScalar();
                        conn.Close();
                    }
                }
                return tcolumn;
            }
            public int GetData2()
            {
                string connection = ConfigurationManager.ConnectionStrings["DB_JDBCLOGConnectionString"].ConnectionString;
                int tcolumn = 0;
                string commandtext = "SELECT Price FROM tblImages WHERE StoreSelection =" + ddlImages.SelectedItem.Value;
                using (SqlConnection conn = new SqlConnection(connection))
                {
                    using (SqlCommand cmds = new SqlCommand(commandtext))
                    {
                        conn.Open();
                        tcolumn = (Int32)cmds.ExecuteScalar();
                        conn.Close();
                    }
                }
                return tcolumn;
            }   
                     
             */ 
             public DataTable GetData(string query)
            {
                DataTable dt = new DataTable();
                string constr = ConfigurationManager.ConnectionStrings["DB_JDBCLOGConnectionString"].ConnectionString;
                using (SqlConnection con = new SqlConnection(constr))
                {
                    using (SqlCommand cmd = new SqlCommand(query,con))
                    {
                        using (SqlDataAdapter sda = new SqlDataAdapter())
                        {
                            cmd.CommandType = CommandType.Text;
                            cmd.Connection = con;
                            sda.SelectCommand = cmd;
                            sda.Fill(dt);
                        }
                    }
                    return dt;
                }
            }
             protected void ds_Selecting(object sender, EventArgs e)
             {
    
                // this.Session["DynamicVariable"] = null;
                 // Create a List of Integer to store selected AddressId
                     for (int iRow = 0; iRow < GridView1.Rows.Count; iRow++)
             {
                 //Find CheckBox control in GridView for particular Row
                 this.Session["DynamicVariable"] = GridView1.Rows[iRow].Cells[0].FindControl("Firstname");
    
                  
                    
                 
             }
             } 
             protected override void InitializeCulture()
             {
                 CultureInfo ci = new CultureInfo("ur-PK");
                 ci.NumberFormat.CurrencySymbol = "Rs";
                 Thread.CurrentThread.CurrentCulture = ci;
                 base.InitializeCulture();
             }
             public void FetchImage(object sender, EventArgs e)
             {
                 int id = Convert.ToInt32(ddlImages.SelectedItem.Value);
                 Session["value"] = id;
    
                 foreach (GridViewRow row in GridView1.Rows)
                 {
                     //Finding Dropdown control  
                     Control ctrl = row.FindControl("ddl2") as DropDownList;
                     if (ctrl != null)
                     {
                         DropDownList ddl1 = (DropDownList)ctrl;
                         ddl1.DataSource = Products(id);
                         ddl1.DataBind();
                     }
                 }
             }
             public void FetchImage2(object sender, EventArgs e)
             {
                 DropDownList ddl1 = (DropDownList)GridView1.FindControl("DropDownList2");
                 int id = Convert.ToInt32(ddlImages.SelectedItem.Value);
                 
    
             }
            /*
            public void FetchImage(object sender, EventArgs e)
            {
                string id = ddlImages.SelectedItem.Value;
                System.Web.UI.WebControls.Image img2=null;
                foreach (GridViewRow rs in GridView1.Rows)
                {
                    GridView1.Rows[rs.RowIndex].Cells[0].Text = GetData1();
                    GridView1.Rows[rs.RowIndex].Cells[1].Text = GetData2().ToString();   
              
                
                         img2 = (System.Web.UI.WebControls.Image)rs.FindControl("Image1");
                }
                   byte[] bytes = (byte[])GetData("SELECT Image FROM tblImages WHERE StoreSelection=" + id).Rows[0]["Image"];
                        string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
                        img2.ImageUrl = "data:image/jpg;base64," + base64String;
                                 
                
            }
             */
            protected void grvMergeHeader_RowCreated(object sender, GridViewRowEventArgs e)
            {
                if (e.Row.RowType == DataControlRowType.Header)
                {
                    GridView HeaderGrid = (GridView)sender;
                    GridViewRow HeaderGridRow = new GridViewRow(5, 5, DataControlRowType.Header, DataControlRowState.Insert);
                    TableCell HeaderCell = new TableCell();
                    HeaderCell.Text = "SUIT STYLES";
                    HeaderCell.ColumnSpan = 2;
                    HeaderGridRow.Cells.Add(HeaderCell);
    
                    HeaderCell = new TableCell();
                    HeaderCell.Text = "AVAILABLE STOCK";
                    HeaderCell.ColumnSpan = 2;
                    HeaderGridRow.Cells.Add(HeaderCell);
    
                    GridView1.Controls[0].Controls.AddAt(0, HeaderGridRow);
                   
                }
            }
    
            public void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
            {
                string id = GridView1.DataKeys[e.RowIndex]["FirstName"].ToString();
    
    
               // this.Session["suits"] = GridView1.DataKeys[e.RowIndex]["FirstName"].ToString();
            }
            protected void SqldsExample_Selecting(object sender, SqlDataSourceCommandEventArgs e)
    {
        if (GridView1.DataKeys.Count > 0)
        {
            // Your code accessing the 1st element in the collection goes here.
            // Remember that DataKeys[0] returns the first element (count >= 1).
    
            // This is safe, since Count is bigger than 0, so there is at least one item. 
            this.Session["comid"] = GridView1.DataKeys[0].Value.ToString();
            // Might still throw an exception, since you're not sure if count = 2.
            //GridView1.DataKeys[1].Value.ToString();
    
            e.Command.Parameters["comid"].Value = GridView1.DataKeys[0].Value.ToString();
        }
        }
                    protected void Button1_Click(object sender, EventArgs e)
            {
                SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DB_JDBCLOGConnectionString"].ConnectionString);
    
                con.Open();
                //Getting a random order number
                Random rs = new Random();
                n = rs.Next();
                String qs = n.ToString();
    
                //iterating through GridView Controls
                foreach (GridViewRow r in GridView1.Rows)
                {
                    CheckBox chk = (CheckBox)r.FindControl("CheckBox2") as CheckBox;
                    if (chk.Checked)
                    {
    
    
    
                        HtmlInputCheckBox cb = r.FindControl("CheckBox2") as HtmlInputCheckBox;
                        if (cb != null)
                        {
                            if (chk.Checked)
                            {
                                r.BackColor = System.Drawing.Color.Red;
    
                            }
                        }
                        String cell_1_Value = GridView1.Rows[r.RowIndex].Cells[1].Text;
                        String cell_2_Value = GridView1.Rows[r.RowIndex].Cells[2].Text; 
                        System.Web.UI.WebControls.Image img = (System.Web.UI.WebControls.Image)r.FindControl("ImageButton1") as ImageButton;
                        TextBox textboxval = (TextBox)r.FindControl("TextBox2") as TextBox;
    
                        SqlCommand cmds = new SqlCommand("getLordcart");
                        cmds.Connection = con;
                        cmds.CommandType = CommandType.StoredProcedure;
    
                        cmds.Parameters.AddWithValue("@ordernums", n);
                        cmds.Parameters.AddWithValue("@username", cell_2_Value);
                        cmds.Parameters.AddWithValue("@password", cell_2_Value);
                        cmds.Parameters.AddWithValue("@price",  Convert.ToInt32(cell_1_Value));
                        cmds.Parameters.AddWithValue("@cart", textboxval.Text);
                        cmds.Parameters.AddWithValue("@phone", phoneval.Text);
                        cmds.ExecuteNonQuery();
                    }
    
    
                }
                con.Close();
                con.Open();
                SqlCommand cmd12 = new SqlCommand("Update dbo.tblLordShopping  set Image=t1.Image from dbo.tblImages t1 inner join dbo.tblLordShopping t2 on t1.Username= t2.Username and Ordernum=@ordernum");
                cmd12.Connection = con;
    
                cmd12.Parameters.Add(new SqlParameter("@ordernum", n));
                cmd12.ExecuteNonQuery();
    
                
                SqlCommand cmd1 = new SqlCommand("updateprice2");
                cmd1.Connection = con;
                cmd1.CommandType = CommandType.StoredProcedure;
                cmd1.ExecuteNonQuery();
                con.Close();
                Response.Redirect("LordsCart.aspx");
                //ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please Write Your Order Number=' +" + n.ToString() + ");document.location.href='/LordsCart.aspx';", true);
            }
            private void PopulatePager(int recordCount, int currentPage)
            {
                List<ListItem> pages = new List<ListItem>();
                int startIndex, endIndex;
                int pagerSpan = 5;
    
                //Calculate the Start and End Index of pages to be displayed.
                double dblPageCount = (double)((decimal)recordCount / Convert.ToDecimal(PageSize));
                int pageCount = (int)Math.Ceiling(dblPageCount);
                startIndex = currentPage > 1 && currentPage + pagerSpan - 1 < pagerSpan ? currentPage : 1;
                endIndex = pageCount > pagerSpan ? pagerSpan : pageCount;
                if (currentPage > pagerSpan % 2)
                {
                    if (currentPage == 2)
                    {
                        endIndex = 5;
                    }
                    else
                    {
                        endIndex = currentPage + 2;
                    }
                }
                else
                {
                    endIndex = (pagerSpan - currentPage) + 1;
                }
    
                if (endIndex - (pagerSpan - 1) > startIndex)
                {
                    startIndex = endIndex - (pagerSpan - 1);
                }
    
                if (endIndex > pageCount)
                {
                    endIndex = pageCount;
                    startIndex = ((endIndex - pagerSpan) + 1) > 0 ? (endIndex - pagerSpan) + 1 : 1;
                }
    
                //Add the First Page Button.
                if (currentPage > 1)
                {
                    pages.Add(new ListItem("First", "1"));
                }
    
                //Add the Previous Button.
                if (currentPage > 1)
                {
                    pages.Add(new ListItem("<<", (currentPage - 1).ToString()));
                }
    
                for (int i = startIndex; i <= endIndex; i++)
                {
                    pages.Add(new ListItem(i.ToString(), i.ToString(), i != currentPage));
                }
    
                //Add the Next Button.
                if (currentPage < pageCount)
                {
                    pages.Add(new ListItem(">>", (currentPage + 1).ToString()));
                }
    
                //Add the Last Button.
                if (currentPage != pageCount)
                {
                    pages.Add(new ListItem("Last", pageCount.ToString()));
                }
                rptPager.DataSource = pages;
                rptPager.DataBind();
            }
    
            protected void Page_Changed(object sender, EventArgs e)
            {
                int pageIndex = int.Parse((sender as LinkButton).CommandArgument);
                this.GetCustomersPageWise(pageIndex);
                //   this.RememberOldValues();   
            }
    
            private void GetCustomersPageWise(int pageIndex)
            {
                SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString);
                {
                    using (SqlCommand cmd = new SqlCommand("GetCustomersPageWise1", con))
                    {
    
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@PageIndex", pageIndex);
                        cmd.Parameters.AddWithValue("@PageSize", PageSize);
                        cmd.Parameters.Add("@RecordCount", SqlDbType.Int, 4);
                        cmd.Parameters["@RecordCount"].Direction = ParameterDirection.Output;
                        con.Open();
                        IDataReader idr = cmd.ExecuteReader();
                        GridView1.DataSource = idr;
                        GridView1.DataBind();
                        idr.Close();
                        con.Close();
                        int recordCount = Convert.ToInt32(cmd.Parameters["@RecordCount"].Value);
                        this.PopulatePager(recordCount, pageIndex);
                    }
                }
            }
    
            protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
            {
                foreach (GridViewRow row in GridView1.Rows)
                {
                    //Finding Dropdown control  
                    Control ctrl = row.FindControl("ddl2") as DropDownList;
                    if (ctrl != null)
                    {
                        DropDownList ddl1 = (DropDownList)ctrl;
                        Session["SuitDesign"] = ddl1.SelectedItem.Text;
                    }
                }
            }
             private void BindDropDownList2(string field)
        {
            DataTable dt = new DataTable();
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString);
                
            try
            {
                con.Open();
                string sqlStatement = "SELECT Suit_Style FROM dbo.NestedSuits inner join on inner join dbo.tblImages t4 on t3.Suit_Style=t4.Firstname WHERE t4.StoreSelection = @Value1";
                SqlCommand sqlCmd = new SqlCommand(sqlStatement, con);
                sqlCmd.Parameters.AddWithValue("@Value1", field);
                SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
                sqlDa.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                     foreach (GridViewRow row in GridView1.Rows)
                        {
                            //Finding Dropdown control  
                            Control ctrl = row.FindControl("ddl2") as DropDownList;
                            if (ctrl != null)
                            {
                                DropDownList ddl1 = (DropDownList)ctrl;
                    ddl1 .DataSource =dt;
                    ddl1 .DataTextField = "StyleRep"; // the items to be displayed in the list items
                    ddl1 .DataValueField = "StyleRep"; // the id of the items displayed
                    ddl1 .DataBind();
                }
            }
                }
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                string msg = "Fetch Error:";
                msg += ex.Message;
                throw new Exception(msg);
            }
            finally
            {
                con.Close();
            }
        }
    
            protected void Button2_Click1(object sender, EventArgs e)
            {
                FetchProducts();
            }
    
           
        }
    }

    <%@ Page Title="" Language="C#" MasterPageFile="~/Shopcart.Master" AutoEventWireup="true" CodeBehind="ShopCart2.aspx.cs" Inherits="ComputerHardwareShopCart.ShopCart2" %><%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>
    
        
    
    
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
        <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>LORDS FASHION DESIGNER</title>
    
         <script type="text/javascript">
             function Redirect() {
                 var selectedval = ddl1.options[ddl1.selectedIndex].value;
                 
                window.location.href = "Demo.aspx?qs=" + selectedval;
            }
        </script>
        <style type="text/css">
    
            .hiddencol { display: none; }
    body
    {
        margin: 0;
        padding: 0;
        height: 100%;
    }
    .modal
    {
        display: none;
        ;
        top: 0px;
        left: 0px;
        background-color: black;
        z-index: 100;
        opacity: 0.8;
        filter: alpha(opacity=60);
        -moz-opacity: 0.8;
        min-height: 100%;
    }
    #divImage
    {
        display: none;
        z-index: 1000;
        ;
        top: 0;
        left: 0;
        background-color: White;
        height: 550px;
        width: 600px;
        padding: 3px;
        border: solid 1px black;
    }
            .newStyle2
            {
                font-family: "Matura MT Script Capitals";
            }
            .newStyle3
            {
                font-family: "Matura MT Script Capitals";
                font-size: large;
                font-weight: 200;
                font-style: italic;
                font-variant: normal;
                text-transform: capitalize;
                color: #000000;
            }
            .newStyle4
            {
                font-family: Algerian;
                font-size: x-large;
                font-weight: 200;
                font-style: italic;
                font-variant: normal;
                text-transform: capitalize;
                color: #000000;
            }
            .newStyle5
            {
                font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
                font-size: large;
                font-weight: bolder;
                font-style: italic;
                font-variant: normal;
                text-transform: capitalize;
                color: #000000;
            }
            .newStyle6
            {
                font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande", "Lucida Sans", Arial, sans-serif;
                font-size: medium;
                font-weight: lighter;
                font-style: normal;
                font-variant: normal;
                text-transform: capitalize;
                color: #000000;
            }
            .auto-style3
            {
                width: 78px;
            }
        </style>
    <script type="text/javascript">
        function LoadDiv(url) {
            var img = new Image();
            var bcgDiv = document.getElementById("divBackground");
            var imgDiv = document.getElementById("divImage");
            var imgFull = document.getElementById("imgFull");
            var imgLoader = document.getElementById("imgLoader");
            imgLoader.style.display = "block";
            img.onload = function () {
                imgFull.src = img.src;
                imgFull.style.display = "block";
                imgLoader.style.display = "none";
            };
            img.src = url;
            var width = document.body.clientWidth;
            if (document.body.clientHeight > document.body.scrollHeight) {
                bcgDiv.style.height = document.body.clientHeight + "px";
            }
            else {
                bcgDiv.style.height = document.body.scrollHeight + "px";
            }
            imgDiv.style.left = (width - 650) / 2 + "px";
            imgDiv.style.top = "20px";
            bcgDiv.style.width = "100%";
    
            bcgDiv.style.display = "block";
            imgDiv.style.display = "block";
            return false;
        }
        function HideDiv() {
            var bcgDiv = document.getElementById("divBackground");
            var imgDiv = document.getElementById("divImage");
            var imgFull = document.getElementById("imgFull");
            if (bcgDiv != null) {
                bcgDiv.style.display = "none";
                imgDiv.style.display = "none";
                imgFull.style.display = "none";
            }
        }
    </script>
    </head>
    <body>
        <center>
        <h1>Please Enter Your Phone Number(no dashes):</h1>
            <p>
                <asp:TextBox ID="phoneval" runat="server" Width="248px"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Please Enter Phone Number" ControlToValidate="phoneval" ForeColor="#CC0000"></asp:RequiredFieldValidator>
            </p>
            <h1>View Stock Items Available</h1>
         <asp:DropDownList ID="ddlImages" runat="server" OnSelectedIndexChanged="FetchImage" AppendDataBoundItems="true" AutoPostBack = "true"> 
        <asp:ListItem Text="Select Items to View" Value="0" />
    </asp:DropDownList>
    
                                         
                                        
       &nbsp;</center>
           
          <div id="divBackground" class="modal">
    </div>
    <div id="divImage">
    <table style="height: 100%; width: 100%">
        <tr>
            <td valign="middle" align="center">
                <img id="imgLoader" alt="" src="Images/accent.png" />
                <img id="imgFull" alt="" src="" style="display: none; height: 500px; width: 590px" />
            </td>
        </tr>
        <tr>
            <td align="center" valign="bottom">
                <input id="btnClose" type="button" value="close" onclick="HideDiv()" />
            </td>
        </tr>
    </table>
    </div>
       
            <center>
                <!-- OnSelectedIndexChanged = "FetchImage"> -->
             
    <hr />
    
                  
                      
                        <asp:Panel ID="Panel8" runat="server" datakeynames="Firstname" Height="664px" style="text-align: left" Width="681px">
                            <asp:GridView ID="GridView1" runat="server" AllowPaging="True"  AllowSorting="true" AutoGenerateColumns="False" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderStyle="None" BorderWidth="5px" CellPadding="3" CellSpacing="2" ForeColor="Black" GridLines="None" Height="611px" OnRowUpdating="GridView1_RowUpdating" OnRowCreated="grvMergeHeader_RowCreated" Width="676px"  style="text-align: center" CssClass="newStyle6" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
                                <EditRowStyle Width="75px" />
                                <FooterStyle BackColor="Tan" />
                                <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
                                <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
                                <HeaderStyle BackColor="Tan" Font-Bold="True" />
                                <AlternatingRowStyle BackColor="PaleGoldenrod" />
                              
                                <Columns>
                                    
                                    <asp:BoundField DataField="Firstname" HeaderText="SUIT DESIGN" SortExpression="Firstname" />
                                    <asp:BoundField DataField="Price" HeaderText="PRICE QUOTE" SortExpression="Price" DataFormatString="{0:C}" HtmlEncode="false" />
                                     <asp:BoundField DataField="Username" SortExpression="Username" ItemStyle-CssClass="hiddencol"  HeaderStyle-CssClass="hiddencol"  />
                                     
                                                              <asp:TemplateField>
                                                                   
                                                                          
                                         
                                      
                                        <ItemTemplate>
                                          
                                <asp:ImageButton ID="ImageButton1" ImageUrl='<%# "data:image/jpg;base64," + Convert.ToBase64String((byte[])Eval("Image")) %>' runat="server"   Width="100px" Height="100px" Style="cursor: pointer" OnClientClick="return LoadDiv(this.src);" />
                                 
                                       
                                                         <asp:Image ID="Image3" runat="server" ImageUrl="~/Images/manifier.jpg" Height="35" Width="25"></asp:Image>
    
                                                       <asp:CheckBox ID="CheckBox2" runat="server" />
                                           
                                        </ItemTemplate>
                                        <HeaderTemplate>
                                            <asp:Image ID="Image1" runat="server" Height="80px" ImageUrl="~/Images/Lords.png" Width="105px" />
                                       
                                        </HeaderTemplate>
                                   
                                                                   </asp:TemplateField>
                                  
                                    <asp:TemplateField>
                                        <ItemTemplate>
                                            <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>&nbsp;&nbsp;&nbsp; <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/tie.jpg" Height="30" Width="35"></asp:Image>
                                        </ItemTemplate>
                                        <HeaderTemplate>
                                            PLEASE ENTER QUANTITY  <asp:Image ID="Image2" runat="server" Height="80px" ImageUrl="~/Images/quantitylords.jpg" Width="105px" />
                                        </HeaderTemplate>
                                    </asp:TemplateField>
                                                                     <asp:TemplateField HeaderText="Additional Suits" SortExpression="StyleRep">
                                    <HeaderTemplate>
                                         Select Additional Suits <asp:Button ID="Button2" runat="server" Text="Additional Suits" OnClick="Button2_Click1"></asp:Button>    
                                    </HeaderTemplate>
    
                                                                              <ItemTemplate>
                                          <asp:DropDownList ID="ddl2" AppendDataBoundItems="true" runat="server" AutoPostBack = "true" OnSelectedIndexChanged="Button2_Click1" onchange="Redirect();">
                                        <asp:ListItem Text="Select Items to View" Value="0" />
                                        </asp:DropDownList>
                                      </ItemTemplate>    
                                        <EditItemTemplate>
                                                                          
                                         <asp:HiddenField ID="hfAttended_by" runat="server" value='<%# Bind("StyleRep") %>'/>      
                                       </EditItemTemplate>
                                       
                                    </asp:TemplateField>
                                </Columns>
                            </asp:GridView>
                           
                          <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DB_JDBCLOGConnectionString2 %>" SelectCommand="SELECT [Firstname],[Image], [Price],[Username] FROM [tblImages]"></asp:SqlDataSource>
                    <br />     
    
    
                            <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
    
    
                    <br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
                    <asp:Button ID="Button1" runat="server" Text="Order Items" OnClick="Button1_Click" />
             <input type="reset" runat="server" Text="Clear All" class="auto-style3" />
                        </asp:Panel>
                    
                           
                  <asp:Repeater ID="rptPager" runat="server">
        <ItemTemplate>
            <asp:LinkButton ID="lnkPage" runat="server" Text='<%#Eval("Text") %>' CommandArgument='<%# Eval("Value") %>'
                CssClass='<%# Convert.ToBoolean(Eval("Enabled")) ? "page_enabled" : "page_disabled" %>'
                OnClick="Page_Changed" OnClientClick='<%# !Convert.ToBoolean(Eval("Enabled")) ? "return false;" : "" %>'></asp:LinkButton>
       </ItemTemplate>
    </asp:Repeater>      
                  
    
                  
    
                 
           </center>
           
    </body>
    </html>
    
    </asp:Content>
    

    Saturday, April 22, 2017 2:51 AM