private void bindData() { PenjaminanDataset.KaryawanRow dr = Karyawan.selectKaryawanByID(eID); Models.PenjaminanDatasetTableAdapters.DivisiTableAdapter ta = new Models.PenjaminanDatasetTableAdapters.DivisiTableAdapter(); DropDownList1.DataSource = (PenjaminanDataset.DivisiDataTable)ta.GetDataByID(dr.DivisiID); DropDownList1.DataBind(); txtName.Value = dr.Nama.ToString(); txtAlamat.Value = dr.Alamat.ToString(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["UserProfile"] == null) { Response.Redirect("/Default.aspx"); } if (!Page.IsPostBack) { if (eType == "add") { } else if (eType == "edit") { bindData(); //PenjaminanDataset.DivisiRow dr = m_divisi.selectDivisiByID(Convert.ToInt16(DropDownList1.Text)); } else if (eType == "delete") { softDeleteData(eID); } } lblMenu.Text = "Entry Master Karyawan"; Session["activepage"] = "karyawan"; if (!Page.IsPostBack) { Models.PenjaminanDatasetTableAdapters.DivisiTableAdapter ta = new Models.PenjaminanDatasetTableAdapters.DivisiTableAdapter(); DropDownList1.DataSource = (PenjaminanDataset.DivisiDataTable)ta.GetData(); DropDownList1.DataBind(); if (eType == "edit") { PenjaminanDataset.KaryawanRow dr = Karyawan.selectKaryawanByID(eID); tDivisiID = dr.DivisiID; DropDownList1.SelectedValue = tDivisiID.ToString(); } //DropDownList1.DataTextFormatString = "{0} - {1}"; //DropDownList1.DataTextField = "ID,NamaDivisi"; } }
public static PenjaminanDataset.KaryawanRow selectKaryawanByID(int id) { PenjaminanDatasetTableAdapters.KaryawanTableAdapter ta = new PenjaminanDatasetTableAdapters.KaryawanTableAdapter(); PenjaminanDataset.KaryawanDataTable dt = new PenjaminanDataset.KaryawanDataTable(); PenjaminanDataset.KaryawanRow dr = null; try { ta.FillByjoin(dt, id); if (dt.Count > 0) { dr = dt[0]; } return(dr); } catch (Exception ex) { throw new ApplicationException("Failed to load Employee data : " + ex.Message); } }