protected void BindData() { try { venderrepo = new vendorRepository(db); var data = venderrepo.GetAll().Where(v => v.TenantId == tenantId).OrderByDescending(o => o.VendorID).ToList(); if (data.Count == 0) { data.Add(new Domain.Vendor() { VendorID = 0, VendorName = "", Address = "", ContactNo = "", BillNo = "" }); gvvendor.DataSource = data; gvvendor.DataBind(); gvvendor.Rows[0].Visible = false; gvvendor.ShowFooter = true; } else { gvvendor.DataSource = data; gvvendor.DataBind(); } } catch (Exception ex) { Response.Write(ex.Message); } finally { //conn.Close(); } }
protected void BindData() { try { //itemRepo = new ItemRepository(db); //var data = itemRepo.GetAll().ToList(); var data = stockingrepo.GetAll().Where(i => i.TenantId == tenantId).OrderByDescending(o => o.StockingId).ToList(); if (data.Count == 0) { data.Add(new Domain.StockingDetail() { ProductId = 0, Quantity = 0, BillNo = "", VendorId = 0, CreationTime = DateTime.Now }); gvItemDetails.DataSource = data; gvItemDetails.DataBind(); gvItemDetails.Rows[0].Visible = false; gvItemDetails.ShowFooter = true; } else { gvItemDetails.DataSource = data; gvItemDetails.DataBind(); } DropDownList ddlAddProduct = (DropDownList)gvItemDetails.FooterRow.FindControl("ddlAddProduct"); Prorepo = new ProductRepository(db); ddlAddProduct.DataSource = Prorepo.GetAll().Where(p => p.TenantId == tenantId).ToList(); ddlAddProduct.DataTextField = "ProductName"; ddlAddProduct.DataValueField = "ProductId"; ddlAddProduct.DataBind(); DropDownList ddlAddvendor = (DropDownList)gvItemDetails.FooterRow.FindControl("ddlAddvendor"); vendorRepo = new vendorRepository(db); ddlAddvendor.DataSource = vendorRepo.GetAll().Where(v => v.TenantId == tenantId).ToList(); ddlAddvendor.DataTextField = "VendorName"; ddlAddvendor.DataValueField = "VendorId"; ddlAddvendor.DataBind(); //DropDownList ddlAddBillno = (DropDownList)gvItemDetails.FooterRow.FindControl("ddlAddBillno"); //vendorRepo = new vendorRepository(db); //ddlAddBillno.DataSource = vendorRepo.GetAll().ToList(); //ddlAddBillno.DataTextField = "Billno"; //ddlAddBillno.DataValueField = "VendorId"; //ddlAddBillno.DataBind(); } catch (Exception ex) { Response.Write(ex.Message); } finally { //conn.Close(); } }
protected void gvItemDetails_RowDataBound(object sender, GridViewRowEventArgs e) { DropDownList ddlProduct = (DropDownList)e.Row.FindControl("ddlEditProduct"); if (ddlProduct != null) { Prorepo = new ProductRepository(db); ddlProduct.DataSource = Prorepo.GetAll().Where(v => v.TenantId == tenantId).ToList(); ddlProduct.DataTextField = "ProductName"; ddlProduct.DataValueField = "ProductId"; ddlProduct.DataBind(); ddlProduct.SelectedValue = gvItemDetails.DataKeys[e.Row.RowIndex].Values[1].ToString(); Label lblPro = (Label)e.Row.FindControl("lblProductId"); if (lblPro != null) { lblPro.Text = "3"; } } DropDownList ddlvendor = (DropDownList)e.Row.FindControl("ddlEditvendor"); if (ddlvendor != null) { stockingrepo = new StockingDetailsRepository(db); vendorRepo = new vendorRepository(db); ddlvendor.DataSource = vendorRepo.GetAll().Where(v => v.TenantId == tenantId).ToList(); ddlvendor.DataTextField = "VendorName"; ddlvendor.DataValueField = "VendorID"; ddlvendor.DataBind(); ddlvendor.SelectedValue = gvItemDetails.DataKeys[e.Row.RowIndex].Values[2].ToString(); Label lblvend = (Label)e.Row.FindControl("lblvendorid"); if (lblvend != null) { lblvend.Text = "3"; } } }