public void listarcompanies() { try { string vLista = ""; String vQuery = "CALL GetAllCompanies();"; DataTable vCompanies = vBaseDatos.ObtenerTabla(vQuery); //CompanyId.DataBind(); if (vCompanies.Rows.Count > 0) { CompanyId.DataSource = vCompanies; CompanyId.DataTextField = "CompanyName"; CompanyId.DataValueField = "CompanyId"; CompanyId.DataBind(); } else { CompanyId.Items.Insert(0, new ListItem("No se obtuvieron compañias", "1")); } //CompanyId.Items.Insert(0, new ListItem("Seleccione una opción", "0")); } catch (Exception) { throw; } }
protected void Page_Load(object sender, EventArgs e) { Int32 LoginUserId = 0; if (HttpContext.Current.Session["UserId"] != null) { LoginUserId = Convert.ToInt32(HttpContext.Current.Session["UserId"].ToString()); } string currentDateString = DateTime.Now.ToString("MM/dd/yyyy"); CreatedBy.Value = "0"; UpdatedBy.Value = "0"; CreatedDate.Value = currentDateString; UpdatedDate.Value = currentDateString; List <Company> companies = ICompanyService.GetData(0, 0, false); CompanyId.DataSource = companies; CompanyId.DataTextField = "Name"; CompanyId.DataValueField = "Id"; CompanyId.DataBind(); string idString = Request.QueryString["id"]; if (idString != null && idString != "") { int id = Convert.ToInt32(idString); Branch obj = IBranchService.GetSingle(id); CompanyId.Value = obj.CompanyId.ToString(); Id.Value = obj.Id.ToString(); Code.Value = obj.Code; Name.Value = obj.Name; Status.Value = obj.Status.ToString(); CreatedBy.Value = obj.CreatedBy.ToString(); CreatedDate.Value = obj.CreatedDate.ToString("MM/dd/yyyy"); UpdatedBy.Value = obj.UpdatedBy.ToString(); UpdatedDate.Value = obj.UpdatedDate == null?DateTime.Now.ToString("MM/dd/yyyy") : obj.UpdatedDate.Value.ToString("MM/dd/yyyy"); IsAll.Value = obj.IsAll.ToString(); } }