protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { List <Gyvunas> bandymas = (List <Gyvunas>)Session["ArrayGyvunai"]; int edit = (int)Session["editId"]; TextBox1.Text = bandymas[edit].vardas; TextBox2.Text = bandymas[edit].gimimo_data.ToShortDateString(); Kontekstas test = new Kontekstas(conString); #region lytys lytysList = test.GetLytis(); Dictionary <int, string> lytys = new Dictionary <int, string>(); foreach (Lytis lytis in lytysList) { lytys.Add(lytis.id, lytis.name); } DropDownList1.DataSource = lytys; DropDownList1.DataTextField = "Value"; DropDownList1.DataValueField = "Key"; DropDownList1.DataBind(); DropDownList1.SelectedValue = bandymas[edit].lytis_id.ToString(); #endregion #region savininkai savininkaiList = test.GetSavininkas(); List <long> savId = new List <long>(); foreach (Savininkas sav in savininkaiList) { savId.Add(sav.id); } DropDownList2.DataSource = savId; DropDownList2.DataBind(); DropDownList2.SelectedValue = bandymas[edit].savininko_kodas.ToString(); #endregion #region isvaizda isvaizdaList = test.GetIsvaizda(); List <int> isvId = new List <int>(); foreach (Isvaizda isv in isvaizdaList) { isvId.Add(isv.id); } DropDownList3.DataSource = isvId; DropDownList3.DataBind(); DropDownList3.SelectedValue = bandymas[edit].fk_Isvaizda_id.ToString(); #endregion #region mikroschema mikrosList = test.GetMikro(); List <int> mikroList = new List <int>(); foreach (Mikro mik in mikrosList) { mikroList.Add(mik.numeris); } DropDownList6.DataSource = mikroList; DropDownList6.DataBind(); DropDownList6.SelectedValue = bandymas[edit].fk_micro_id.ToString(); #endregion #region registracija regList = test.GetRegistracija(); List <int> registNr = new List <int>(); foreach (Registracija reg in regList) { registNr.Add(reg.numeris); } DropDownList7.DataSource = registNr; DropDownList7.DataBind(); DropDownList7.SelectedValue = bandymas[edit].fk_reg_id.ToString(); #endregion #region sveikata sveikList = test.GetSveikata(); List <DateTime> datuList = new List <DateTime>(); foreach (Sveikata sveik in sveikList) { datuList.Add(sveik.Vizito_data.Date); } DropDownList5.DataSource = datuList; DropDownList5.DataBind(); DropDownList5.SelectedValue = bandymas[edit].fk_vet_viz.ToShortDateString(); #endregion #region veisle veislList = test.GetVeisle(); List <string> veisles = new List <string>(); foreach (Veisle veis in veislList) { veisles.Add(veis.pavadinimas); } DropDownList4.DataSource = veisles; DropDownList4.DataBind(); DropDownList4.SelectedValue = bandymas[edit].fk_veisle; #endregion } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Kontekstas test = new Kontekstas(conString); #region lytys lytysList = test.GetLytis(); Dictionary <int, string> lytys = new Dictionary <int, string>(); foreach (Lytis lytis in lytysList) { lytys.Add(lytis.id, lytis.name); } DropDownList1.DataSource = lytys; DropDownList1.DataTextField = "Value"; DropDownList1.DataValueField = "Key"; DropDownList1.DataBind(); #endregion #region savininkai savininkaiList = test.GetSavininkas(); List <long> savId = new List <long>(); foreach (Savininkas sav in savininkaiList) { savId.Add(sav.id); } DropDownList2.DataSource = savId; DropDownList2.DataBind(); #endregion #region isvaizda isvaizdaList = test.GetIsvaizda(); List <int> isvId = new List <int>(); foreach (Isvaizda isv in isvaizdaList) { isvId.Add(isv.id); } DropDownList3.DataSource = isvId; DropDownList3.DataBind(); #endregion #region mikroschema mikrosList = test.GetMikro(); List <int> mikroList = new List <int>(); foreach (Mikro mik in mikrosList) { mikroList.Add(mik.numeris); } DropDownList5.DataSource = mikroList; DropDownList5.DataBind(); #endregion #region registracija regList = test.GetRegistracija(); List <int> registNr = new List <int>(); foreach (Registracija reg in regList) { registNr.Add(reg.numeris); } DropDownList6.DataSource = registNr; DropDownList6.DataBind(); #endregion #region sveikata sveikList = test.GetSveikata(); List <DateTime> datuList = new List <DateTime>(); foreach (Sveikata sveik in sveikList) { datuList.Add(sveik.Vizito_data.Date); } DropDownList4.DataSource = datuList; DropDownList4.DataBind(); #endregion #region veisle veislList = test.GetVeisle(); List <string> veisles = new List <string>(); foreach (Veisle veis in veislList) { veisles.Add(veis.pavadinimas); } DropDownList7.DataSource = veisles; DropDownList7.DataBind(); #endregion } }