protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; LoadColors(); if (Request.QueryString["ID"] != null) { if (Request.QueryString["ID"] == "True") { lblMsg.Text = "Successfully Edited"; } } if (Request.QueryString["ProductColorId"] != null) { int productColorId = Convert.ToInt32(Request.QueryString["ProductColorId"]); dtProductColors = taProductColors.SelectProductColorByProductColorId(productColorId); if (dtProductColors.Rows.Count > 0) { int productId = Convert.ToInt32(dtProductColors[0].ProductId); dtProduct = taProduct.SelectProductNamebyProductId(productId); if (dtProduct.Rows.Count > 0) { lblProductTitle.Text = dtProduct[0].ProductTitle.ToString(); ddlColors.Items.FindByValue(dtProductColors[0].ColorId.ToString()).Selected = true; txtSortOrder.Text = dtProductColors[0].Sort.ToString(); lblImage.Text = dtProductColors[0].Image.ToString(); if (lblImage.Text != "") { Image1.ImageUrl = "~/thumbnail.aspx?image=Images/ProductColorImages/" + lblImage.Text + "&size=150"; } } else { lblMsg.Text = "No product found against the provide productcolorid"; tblColor.Visible = false; } } else { lblMsg.Text = "No record found"; tblColor.Visible = false; } } else { lblMsg.Text = "No record found"; tblColor.Visible = false; } }
private void BindData() { if (Request.QueryString["ProductId"] != null) { int productId = Convert.ToInt32(Request.QueryString["ProductId"]); dtProduct = taProduct.SelectProductNamebyProductId(Convert.ToInt32(Request.QueryString["ProductId"])); if (dtProduct.Rows.Count > 0) { lblProductTitle.Text = "against " + dtProduct[0].ProductTitle.ToString(); } else { btnAdd.Visible = false; lblMsg.Text = "No record found."; return; } dtProductColors = taProductColors.SelectProductColorsByProductId(productId); if (dtProductColors.Rows.Count > 0) { GridView1.DataSource = dtProductColors; GridView1.DataBind(); } else { GridView1.Visible = false; lblMsg.Text = "No record found."; } } }