protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { using (DataClassesDatabaseDataContext db = new DataClassesDatabaseDataContext()) { TBProyeksi[] daftarProyeksi = db.TBProyeksis.OrderByDescending(item => item.TanggalProyeksi).ToArray(); DropDownListCariIDProyeksi.DataSource = daftarProyeksi.Where(item => item.IDProyeksi != null).Select(item => new { item.IDProyeksi }).Distinct(); DropDownListCariIDProyeksi.DataTextField = "IDProyeksi"; DropDownListCariIDProyeksi.DataValueField = "IDProyeksi"; DropDownListCariIDProyeksi.DataBind(); DropDownListCariIDProyeksi.Items.Insert(0, new ListItem { Value = "0", Text = "-Semua-" }); DropDownListCariPegawai.DataSource = daftarProyeksi.Select(item => new { item.IDPengguna, item.TBPengguna.NamaLengkap }).Distinct(); DropDownListCariPegawai.DataTextField = "NamaLengkap"; DropDownListCariPegawai.DataValueField = "IDPengguna"; DropDownListCariPegawai.DataBind(); DropDownListCariPegawai.Items.Insert(0, new ListItem { Value = "0", Text = "-Semua-" }); LoadData(db.TBProyeksis.ToArray()); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { using (DataClassesDatabaseDataContext db = new DataClassesDatabaseDataContext()) { PenggunaLogin pengguna = (PenggunaLogin)Session["PenggunaLogin"]; DropDownListCariBulan.SelectedValue = DateTime.Now.Month.ToString(); DropDownListCariTahun.Items.Insert(0, new ListItem { Value = (DateTime.Now.Year - 2).ToString(), Text = (DateTime.Now.Year - 2).ToString() }); DropDownListCariTahun.Items.Insert(1, new ListItem { Value = (DateTime.Now.Year - 1).ToString(), Text = (DateTime.Now.Year - 1).ToString() }); DropDownListCariTahun.Items.Insert(2, new ListItem { Value = DateTime.Now.Year.ToString(), Text = DateTime.Now.Year.ToString() }); DropDownListCariTahun.SelectedIndex = 2; DropDownListCariPegawai.DataSource = db.TBPenggunas; DropDownListCariPegawai.DataTextField = "NamaLengkap"; DropDownListCariPegawai.DataValueField = "IDPengguna"; DropDownListCariPegawai.DataBind(); DropDownListCariPegawai.Items.Insert(0, new ListItem { Value = "0", Text = "-Semua-" }); DropDownListCariVendor.DataSource = db.TBVendors; DropDownListCariVendor.DataTextField = "Nama"; DropDownListCariVendor.DataValueField = "IDVendor"; DropDownListCariVendor.DataBind(); DropDownListCariVendor.Items.Insert(0, new ListItem { Value = "0", Text = "-Semua-" }); LoadData(); } } }