コード例 #1
0
        private void Load_Data_Grid(int id)
        {
            Product           repository = new Product();
            ProductVendorLink repo       = new ProductVendorLink();
            var result = repository.GetAll().ToArray();

            gridProduct.DataSource = result;
            gridProduct.DataBind();

            var tbl2 = repo.Get(id);

            foreach (GridViewRow row in gridProduct.Rows)
            {
                CheckBox cb = (CheckBox)row.FindControl("CheckBox1");
                if (tbl2 != null)
                {
                    foreach (var t in tbl2)
                    {
                        if (t.ProductId == Convert.ToInt32(gridProduct.DataKeys[row.RowIndex].Value))
                        {
                            cb.Checked = true;
                        }
                    }
                }
            }
        }
コード例 #2
0
        private void Load_Data_Grid()
        {
            ProductVendorLink repository = new ProductVendorLink();
            var result = repository.Get(id);

            if (result != null)
            {
                gridProduct.DataSource = result;
                gridProduct.DataBind();
            }
        }