// gridview events
    protected void gvAdmin_DataBound(object sender, EventArgs e)
    {
        foreach (GridViewRow row in gvAdmin.Rows)
        {
            int key = (int)gvAdmin.DataKeys[row.RowIndex].Value;
            if (row.RowType == DataControlRowType.DataRow)
            {
                DropDownList ddlSkus = (DropDownList)row.FindControl("ddlsku");

                productManager objprod = new productManager();
                DataTable      dt      = new DataTable();
                dt = objprod.BindAllSkuDDL();
                try
                {
                    if (dt.Rows.Count > 0)
                    {
                        ddlSkus.DataSource     = dt;
                        ddlSkus.DataTextField  = "sku";
                        ddlSkus.DataValueField = "productid";
                        ddlSkus.DataBind();

                        Label sku       = (Label)row.FindControl("hidsku");
                        Label productid = (Label)row.FindControl("lblProductid");
                        if (sku.Text != null && sku.Text != "")
                        {
                            //ddlSkus.SelectedItem.Text = sku.Text;
                            ddlSkus.SelectedValue = productid.Text;
                        }
                        else
                        {
                            ddlSkus.Items.Insert(0, new ListItem(" search ", "0"));
                        }

                        //ddlSkus.Items.Insert(0, new ListItem("Select", "0"));
                    }
                    else
                    {
                        ddlSkus.Items.Insert(0, new ListItem(" search ", "0"));
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally { objprod = null; dt = null; }
            }
        }
    }
    //handle row data bound
    protected void gvAdmin_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            HiddenField hdmenuimage = new HiddenField();
            hdmenuimage = (HiddenField)e.Row.FindControl("hdmenuimage");

            HtmlImage imgMenu = new HtmlImage();
            imgMenu = (HtmlImage)e.Row.FindControl("imgMenu");

            HtmlAnchor imgAnc = new HtmlAnchor();
            imgAnc = (HtmlAnchor)e.Row.FindControl("ancImage");

            if (hdmenuimage.Value != "")
            {
                string strPath = Server.MapPath("../resources/product/thumb/") + hdmenuimage.Value.ToString();
                if (System.IO.File.Exists(strPath))
                {
                    imgMenu.Src = "../resources/product/thumb/" + hdmenuimage.Value.ToString();
                    imgAnc.HRef = "../resources/product/thumb/" + hdmenuimage.Value.ToString();
                }
                else
                {
                    imgMenu.Src = "../images/noimage.png";
                    imgAnc.HRef = "../images/noimage.png";
                }
            }
            else
            {
                imgMenu.Src = "../images/noimage.png";
                imgAnc.HRef = "../images/noimage.png";
            }
        }

        if (Session["AdminType"] != null && Convert.ToString(Session["AdminType"]) == "subadmin")
        {
            e.Row.Cells[0].Visible = false;
        }
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (Convert.ToInt32(gvAdmin.DataKeys[e.Row.RowIndex].Value) == Convert.ToInt32(Session["AdminId"]))
            {
                CheckBox chk = (CheckBox)e.Row.FindControl("chkDelete");
                chk.Enabled = false;
            }
        }

        if (e.Row.RowType == DataControlRowType.Header)
        {
            //Call the GetSortColumnIndex helper method to determine the index of the column being sorted.
            int sortColumnIndex = GetSortColumnIndex();
            if (sortColumnIndex != -1)
            {
                //Call the AddSortImage helper method to add a sort direction image to the appropriate column header.
                AddSortImage(sortColumnIndex, e.Row);
            }
        }

        // bind drop donwlist

        if (e.Row.RowType == DataControlRowType.DataRow && gvAdmin.EditIndex == e.Row.RowIndex)
        {
            DropDownList ddlCities = (DropDownList)e.Row.FindControl("ddlsku");
            Label        lblskus   = (Label)e.Row.FindControl("lblCity");

            productManager objprod = new productManager();
            DataTable      dt      = new DataTable();
            dt = objprod.BindAllSkuDDL();
            try
            {
                ddlCities.DataSource     = dt;
                ddlCities.DataTextField  = "sku";
                ddlCities.DataValueField = "productid";
                ddlCities.DataBind();
                if (lblskus.Text == "")
                {
                    ddlCities.Items.Insert(0, new ListItem("search", "0"));
                }
                else
                {
                    ddlCities.Items.FindByText(lblskus.Text).Selected = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally { dt = null; }
        }
    }