protected void Set_initial() { //initial values of all invoice var NewId = Convert.ToInt32(db.SalesInvoice.Select(item => item.Id).Max()) + 1; InvoiceNo.Text = NewId.ToString(); InvoiceDate.Text = DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day; SalesInvoiceDetailList = new List <SalesInvoiceDetail>(); //make custom For Product (innerDetails) >>><<<< string vgId = Guid.NewGuid().ToString(); ProdNameFilt.ValidationGroup = vgId; ProductPrice.ValidationGroup = vgId; RequiredFieldValidator4.ValidationGroup = vgId; Qty.ValidationGroup = vgId; RequiredFieldValidator1.ValidationGroup = vgId; Save_prodcut.ValidationGroup = vgId; //Product (For Adding will be forced to choose) ProductList = db.Product.ToList(); BindDropDownList(ProductList, ProductListtxt); //Cars (For Adding will be forced to choose) CarsList = db.Cars.ToList(); CarsListtxt.DataSource = CarsList; CarsListtxt.DataTextField = "CarNo"; CarsListtxt.DataValueField = "Id"; CarsListtxt.DataBind(); //ServicesList (For Adding will be forced to choose) ServicesList = db.Services.ToList(); ServicesListtxt.DataSource = ServicesList; ServicesListtxt.DataTextField = "Name"; ServicesListtxt.DataValueField = "Id"; ServicesListtxt.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CarsList = db.Cars.ToList(); List <Cars> TempCarsList = new List <Cars>(); TempCarsList.Add(new Cars { CarNo = "-- select Car Number --", id = 0 }); TempCarsList.AddRange(CarsList); CarsListtxt.DataSource = TempCarsList; CarsListtxt.DataBind(); CarsListtxt.DataTextField = "CarNo"; CarsListtxt.DataValueField = "Id"; CarsListtxt.DataBind(); SalesInvoiceList = db.SalesInvoice.ToList(); } BindGridList(); }