private void BindProductList() { DataTable dtProductList = new DataTable(); gvProductList.DataSource = pr.GetProductDetails(); gvProductList.DataBind(); DataTable dtBuyerProdList = buyerObj.BuyerProductList(Session["BuyerId"].ToString()); if (dtBuyerProdList.Rows.Count > 0) { foreach (DataRow dr in dtBuyerProdList.Rows) { for (int count = 0; count < gvProductList.Rows.Count; count++) { if (gvProductList.DataKeys[count].Value.ToString().Trim() == dr["ProductID"].ToString()) { (gvProductList.Rows[count].Cells[0].FindControl("cbitem") as CheckBox).Checked = true; } } } } }