protected void Page_Load(object sender, EventArgs e) { MessageLabel.Text = ""; //the dropdownnlist (DDL) control will be loaded with Data from the Data Base //Consideration needs to be given to the data as to it change frequence //if your data does not change frequently, you can consider loading on page load if (!Page.IsPostBack) { //use user friendly error handling try { //create and connect to the appropriate BLL Class CategoryController sysmgr = new CategoryController(); //issue the request to the appropriate BLL class method and capture results List <Category> datainfo = sysmgr.Category_List(); // Optional: sort results datainfo.Sort((x, y) => x.CategoryName.CompareTo(y.CategoryName));//ascending //Attach data source collection to DDL CategoryList.DataSource = datainfo; //set DDL DataTextField and Data DataValueField Properties CategoryList.DataTextField = nameof(Category.CategoryName); CategoryList.DataValueField = "CategoryID"; //Physically bind the data to the DDL control CategoryList.DataBind(); // Optional: add a prompt to the DDL control CategoryList.Items.Insert(0, "select..."); } catch (Exception ex) { MessageLabel.Text = ex.Message; } } }
protected void Page_Load(object sender, EventArgs e) { //clear old messages MessageLabel.Text = ""; //load the dropdownlist on the first time processing this page if (!Page.IsPostBack) { //all calls should be done in user friendly error handling try { //when the page is first loaded, obtain the // complete list of categories from the // database CategoryController sysmgr = new CategoryController(); List <Category> datainfo = sysmgr.Category_List(); //sort this list alphabetically datainfo.Sort((x, y) => x.CategoryName.CompareTo(y.CategoryName)); // assign the data to the dropdownlist control CategoryList.DataSource = datainfo; //indicate the DataTextField and DataValueField CategoryList.DataTextField = nameof(Category.CategoryName); CategoryList.DataValueField = nameof(Category.CategoryID); //Bind the datasource CategoryList.DataBind(); //add a prompt CategoryList.Items.Insert(0, "select ..."); } catch (Exception ex) { MessageLabel.Text = ex.Message; } } }
protected void Page_Load(object sender, EventArgs e) { if (!(Request.IsAuthenticated && EmployeeId.HasValue)) { Response.Redirect("~/Account/Login", true); } //else if (!User.IsInRole(Settings.ClerkRole)) //{ // Response.Redirect("~/Account/Login", true); //} var controller2 = new eRaceController(); var employee = controller2.GetEmployeeName(EmployeeId); EmployeeUser.Text = $"Hello there! {employee.UserName} ({employee.EmployeeRole})"; if (!IsPostBack) { var controller = new SalesController(); var date = controller.ListCategory(); CategoryList.DataSource = date; CategoryList.DataTextField = nameof(CategoryInfo.CategoryName); CategoryList.DataValueField = nameof(CategoryInfo.ID); CategoryList.DataBind(); CategoryList.Items.Insert(0, new ListItem("select a category", "0")); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //CsProvince ProvinceList = new CsProvincelist(ProvinceTable); CsItemCat ItemCat = new CsItemCat(CategoryTable); try { ConnectionClass.GetItemCat(ItemCat); CategoryList.DataSource = ItemCat.itemCategory; CategoryList.DataTextField = ItemCat.itemCategory.Columns["categoryName"].ToString(); CategoryList.DataValueField = ItemCat.itemCategory.Columns["categoryCode"].ToString(); CategoryList.DataBind(); } finally { } for (int i = 0; i <= 100; i++) { qtyList.Items.Add(new ListItem(i.ToString(), i.ToString())); } } }
protected void Page_Load(object sender, EventArgs e) { //Clear out old messages. MessageLabel.Text = ""; //Load the dropdownlist (ddl) control with a sorted list of categories. //This load will be done once when the page first is processed. if (!Page.IsPostBack) { //Need to use user friendly error handling. try { //The data collection will come from the db. //Create and connect to the appropriate BLL class. CategoryController sysmgr = new CategoryController(); //Issue a request for data via the appropriate BLL class method. List <Category> datainfo = sysmgr.Category_List(); //Optionally: Sort the collection datainfo.Sort((x, y) => x.CategoryName.CompareTo(y.CategoryName)); //Ascending; swap x and y for desc. //Attach the data to the DDL control CategoryList.DataSource = datainfo; //Indicate the data properties for DataTextField and DataValueField CategoryList.DataTextField = nameof(Category.CategoryName); CategoryList.DataValueField = nameof(Category.CategoryID); //Physically bind the data to the DDL. CategoryList.DataBind(); //Optionally: Place a prompt on the DDL. CategoryList.Items.Insert(0, "select..."); } catch (Exception ex) { MessageLabel.Text = ex.Message; } } }
private void BindData() { int ForumID = 0; CategoryList.DataSource = YAF.Classes.Data.DB.category_list(PageContext.PageBoardID, null); CategoryList.DataBind(); if (Request.QueryString ["f"] != null) { ForumID = Convert.ToInt32(Request.QueryString ["f"]); AccessList.DataSource = YAF.Classes.Data.DB.forumaccess_list(ForumID); AccessList.DataBind(); } // Load forum's combo BindParentList(); // Load forum's themes ListItem listheader = new ListItem(); listheader.Text = "Choose a theme"; listheader.Value = ""; AccessMaskID.DataBind(); ThemeList.DataSource = YafStaticData.Themes(); ThemeList.DataTextField = "Theme"; ThemeList.DataValueField = "FileName"; ThemeList.DataBind(); ThemeList.Items.Insert(0, listheader); }
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { Butonvisible(true); panelVisible(false, true, false, false); List <string> languageList = (from l in db.Language where l.IsActive == true select l.LanguageName).ToList(); ddlLanguage.DataSource = languageList; ddlLanguage.DataBind(); ddlFilterLanguage.DataSource = languageList; ddlFilterLanguage.DataBind(); ddlFilterLanguage.Items.Insert(0, new ListItem("Dil Seçiniz..", "0")); ddlFilterLanguage.SelectedIndex = 0; } CategoryList.DataSource = (from sc in db.SolutionCategory select sc).ToList(); CategoryList.DataBind(); ((Master)this.Master).Path = "Çözüm Kategori"; ((Master)this.Master).PathLink = "SolutionCategoryPage.aspx"; } catch (Exception) { Uyari("Bir Hata Oluştu!", false); pnlAlert.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { MessageLabel.Text = ""; //The ddl control will be loaded with data form the database //Considerations need to be given to the data as to its change frequency //If your data doesn't change frequenly, you an load data on page load if (!Page.IsPostBack) { //Use user frienly error handling try { //Create and connect to the appropriate dll class CategoryController sysmgr = new CategoryController(); //Issue the request to the appropriate dll class method and capture results List <Category> datainfo = sysmgr.Category_List(); //Optionally sort the result datainfo.Sort((x, y) => x.CategoryName.CompareTo(y.CategoryName)); //Attach data source collection to the ddl CategoryList.DataSource = datainfo; //Set the DataTextField and the DataValueField props CategoryList.DataTextField = "CategoryName"; CategoryList.DataValueField = "CategoryID"; //Physically bind the data to the ddl control CategoryList.DataBind(); //Optionally add a prompt to the ddl control CategoryList.Items.Insert(0, "Select..."); } catch (Exception ex) { MessageLabel.Text = ex.Message; } } }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(CssClass)) { MainPanel.CssClass = CssClass; } if (!string.IsNullOrEmpty(HeaderCssClass)) { HeaderPanel.CssClass = HeaderCssClass; } if (!string.IsNullOrEmpty(HeaderText)) { HeaderTextLabel.Text = HeaderText; } if (!string.IsNullOrEmpty(ContentCssClass)) { ContentPanel.CssClass = ContentCssClass; } if (_CategoryId < 0) { _CategoryId = AbleCommerce.Code.PageHelper.GetCategoryId(); } IList <Category> subCategories = GetSubcategories(_CategoryId); CategoryList.DataSource = subCategories; CategoryList.DataBind(); if (subCategories.Count == 0) { CategoryList.Visible = false; NoSubcategoryMessage.Visible = true; } }
protected void CategoryBind() { List <WMGoodCategories> roots = WMGoodCategories.GetList(); if (!General.IsNullable(roots)) { List <WMGoodCategories> list = new List <WMGoodCategories>(); foreach (WMGoodCategories rc in roots) { list.Add(rc); List <WMGoodCategories> subs = WMGoodCategories.GetList(rc.Id); if (!General.IsNullable(subs)) { foreach (WMGoodCategories sub in subs) { sub.Name = " |-- " + sub.Name; } list.AddRange(subs); } } CategoryList.DataSource = list; CategoryList.DataBind(); } }
// Press UpdateButton protected void btnUpdate_Click(object sender, EventArgs e) { //Enable to use textbox, dropdownlist, enable to see upload control AbleTextBoxes(Page); //Enable to see upload button btnUpload.Visible = true; // Input qty list numbers qtyList.SelectedItem.Text = "Please Select"; for (int i = 1; i <= 100; i++) { qtyList.Items.Add(new ListItem(i.ToString(), i.ToString())); } // Input category list items CategoryList.SelectedItem.Text = "Please Select"; CsItemCat Itemcats = new CsItemCat(CategoryTable); ConnectionClass.GetItemCat(Itemcats); CategoryList.DataSource = Itemcats.itemCategory; CategoryList.DataTextField = Itemcats.itemCategory.Columns["categoryName"].ToString(); CategoryList.DataValueField = Itemcats.itemCategory.Columns["categoryName"].ToString(); CategoryList.DataBind(); btnUpdate.Visible = false; btnSave.Visible = true; }
protected void Page_Load(object sender, EventArgs e) { brandchanged = false; spec1changed = false; spec2changed = false; spec3changed = false; spec4changed = false; spec5changed = false; spec6changed = false; spec7changed = false; Label15.Text = DateTime.Now.ToString(); if (!IsPostBack) { generateOrderID(); Specification1.Visible = false; SpecificationRList1.Visible = false; Specification2.Visible = false; SpecificationRList2.Visible = false; Specification3.Visible = false; SpecificationRList3.Visible = false; Specification4.Visible = false; SpecificationRList4.Visible = false; Specification5.Visible = false; SpecificationRList5.Visible = false; Specification6.Visible = false; SpecificationRList6.Visible = false; Specification7.Visible = false; SpecificationRList7.Visible = false; Button4.Visible = false; conn = new MySqlConnection(GetConnectionString()); try { conn.Open(); MySqlCommand comm = new MySqlCommand("Select Category_Name,Category_ID from Category", conn); MySqlDataReader dr = comm.ExecuteReader(); CategoryList.DataSource = dr; CategoryList.DataTextField = "Category_Name"; CategoryList.DataValueField = "Category_ID"; CategoryList.DataBind(); dr.Close(); } catch (Exception em) { Response.Write("in page load"); Response.Write(em.Message); } finally { conn.Close(); } } CategoryList.Items.Insert(0, new ListItem("", "0")); }
private void LoadCategories() { using (dbModelContainer db = new dbModelContainer()) { var categories = db.Category.ToList(); CategoryList.DataSource = categories; CategoryList.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // Define data objects OracleConnection conn; OracleCommand categoryComm; OracleCommand subjectComm; OracleDataReader reader; // Read the connection string from Web.config string connectionString = ConfigurationManager.ConnectionStrings[ "Oracle1ConnectionString"].ConnectionString; // Initialize connection conn = new OracleConnection(connectionString); // Create command to read the help desk categories categoryComm = new OracleCommand( "SELECT CategoryID, Category FROM HelpDeskCategories", conn); // Create command to read the help desk subjects subjectComm = new OracleCommand( "SELECT SubjectID, Subject FROM HelpDeskSubjects", conn); // Enclose database code in Try-Catch-Finally try { // Open the connection conn.Open(); // Execute the category command reader = categoryComm.ExecuteReader(); // Populate the list of categories CategoryList.DataSource = reader; CategoryList.DataValueField = "CategoryID"; CategoryList.DataTextField = "Category"; CategoryList.DataBind(); // Close the reader reader.Close(); // Execute the subjects command reader = subjectComm.ExecuteReader(); // Populate the list of subjects SubjectList.DataSource = reader; SubjectList.DataValueField = "SubjectID"; SubjectList.DataTextField = "Subject"; SubjectList.DataBind(); // Close the reader reader.Close(); } finally { // Close the connection conn.Close(); } } }
private void LoadCategoryList() { ITermController termController = Util.GetTermController(); CategoryList.DataSource = termController.GetTermsByVocabulary("Module_Categories").OrderBy(t => t.Weight).Where(t => t.Name != "< None >").ToList(); CategoryList.DataBind(); CategoryList.AddItem(Localization.GetString("AllCategories", LocalResourceFile), "All"); if (!IsPostBack) { CategoryList.Select("All", false); } }
//******************************************************* // // BindCategoryList method databinds data to CategoryList dropdown. // //******************************************************* private void BindCategoryList() { if (ProjectList.SelectedItem != null) { // CategoryList is different for each project, Project.GetCategories gets a list of // categories based on the project. CategoryList.DataSource = Project.GetCategories(Convert.ToInt32(ProjectList.SelectedItem.Value)); CategoryList.DataValueField = "CategoryID"; CategoryList.ToolTip = "Abbreviation"; CategoryList.DataTextField = "Name"; CategoryList.DataBind(); } }
private void LoadCategoryList() { CategoryListPanel.Visible = !AddExistingModule.Checked; ITermController termController = Util.GetTermController(); CategoryList.DataSource = termController.GetTermsByVocabulary("Module_Categories").OrderBy(t => t.Weight).Where(t => t.Name != "< None >").ToList(); CategoryList.DataBind(); //CategoryList.Items.Add(new ListItem(Localization.GetString("AllCategories", LocalResourceFile), "All")); CategoryList.AddItem(Localization.GetString("AllCategories", LocalResourceFile), "All"); if (!IsPostBack) { CategoryList.Select("Common", false); } }
private void LoadCategoryList() { ITermController termController = Util.GetTermController(); var terms = termController.GetTermsByVocabulary("Module_Categories").OrderBy(t => t.Weight).Where(t => t.Name != "< None >").ToList(); var allTerm = new Term("All", Localization.GetString("AllCategories", LocalResourceFile)); terms.Add(allTerm); CategoryList.DataSource = terms; CategoryList.DataBind(); if (!IsPostBack) { CategoryList.Select(!String.IsNullOrEmpty(BookmarkedModuleKeys) ? BookmarkModuleCategory : "All", false); } }
public void BindCategoryList() { try { CategoryController sysmgr = new CategoryController(); // sysmgr is just a variable name Don likes to use List <Category> info = sysmgr.Category_List(); info.Sort((x, y) => x.CategoryName.CompareTo(y.CategoryName)); CategoryList.DataSource = info; CategoryList.DataTextField = nameof(Category.CategoryName); CategoryList.DataValueField = nameof(Category.CategoryID); CategoryList.DataBind(); CategoryList.Items.Insert(0, "select..."); } catch (Exception ex) { errormsgs.Add("File Error: " + GetInnerException(ex).Message); LoadMessageDisplay(errormsgs, "alert alert-warning"); } }
protected void BindCategoryList() { try { CategoryController sysmgr = new CategoryController(); List <Category> datainfo = sysmgr.Category_List(); datainfo.Sort((x, y) => x.CategoryName.CompareTo(y.CategoryName)); CategoryList.DataSource = datainfo; CategoryList.DataTextField = nameof(Category.CategoryName); CategoryList.DataValueField = nameof(Category.CategoryID); CategoryList.DataBind(); CategoryList.Items.Insert(0, "..select"); } catch (Exception ex) { errormsgs.Add(GetInnerException(ex).Message); LoadMessageDisplay(errormsgs, "alert alert-danger"); } }
protected void Page_Init(object sender, EventArgs e) { if (Session["AId"] == null) { Response.Redirect("~/default.aspx"); } SqlDataSource SqlDataSource1 = new SqlDataSource(); SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; SqlDataSource1.SelectCommand = "SELECT [category_id], [category_name] FROM [Category]"; CategoryList.DataSource = SqlDataSource1; CategoryList.DataTextField = "category_name"; CategoryList.DataValueField = "category_id"; CategoryList.DataBind(); SqlDataSource1.Dispose(); }
protected void BindCategoryList() { try { Controller01 sysmgr = new Controller01(); List <Entity01> info = null; info = sysmgr.List(); info.Sort((x, y) => x.CategoryName.CompareTo(y.CategoryName)); CategoryList.DataSource = info; CategoryList.DataTextField = nameof(Entity01.CategoryName); CategoryList.DataValueField = nameof(Entity01.CategoryID); CategoryList.DataBind(); CategoryList.Items.Insert(0, "select..."); } catch (Exception ex) { errormsgs.Add(GetInnerException(ex).ToString()); LoadMessageDisplay(errormsgs, "alert alert-danger"); } }
protected void BindCategoryList() { //this will be a standard lookup for the Category record try { CategoryController sysmgr = new CategoryController(); List<Category> info = null; info = sysmgr.Categories_List(); info.Sort((x, y) => x.CategoryName.CompareTo(y.CategoryName)); CategoryList.DataSource = info; CategoryList.DataTextField = nameof(Category.CategoryName); CategoryList.DataValueField = nameof(Category.CategoryID); CategoryList.DataBind(); CategoryList.Items.Insert(0, "select..."); } catch (Exception ex) { MessageLabel.Text = ex.Message; } }
public void BindCategoryList() { //TODO: code the method to load the CategoryList control try { CategoryController sysmgr = new CategoryController(); List <Category> info = sysmgr.Categories_List(); info.Sort((x, y) => x.CategoryName.CompareTo(y.CategoryName)); CategoryList.DataSource = info; CategoryList.DataTextField = nameof(Category.CategoryName); CategoryList.DataValueField = nameof(Category.CategoryID); CategoryList.DataBind(); CategoryList.Items.Insert(0, "select ..."); } catch (Exception ex) { errormsgs.Add("File Error: " + GetInnerException(ex).Message); LoadMessageDisplay(errormsgs, "alert alert-warning"); } }
protected void Page_Load(object sender, EventArgs e) { test.Text = (string)Session["ConsumableName"]; AmountLabel.Text = new ConsumablesMapper().SelectByName(test.Text).Portion.ToString() + "g"; if (!IsPostBack) { List <ListItem> list = new List <ListItem>(); list.Add(new ListItem("Breakfast", "1")); list.Add(new ListItem("Break", "2")); list.Add(new ListItem("Lunch", "3")); list.Add(new ListItem("Dinner", "4")); CategoryList.DataSource = list; CategoryList.DataTextField = "text"; CategoryList.DataValueField = "value"; CategoryList.DataBind(); } }
protected void BindCategoryList() { //this will be a standard lookup for the Category records try { CategoryController sysmgr = new CategoryController(); List <Category> info = null; info = sysmgr.Categories_List(); info.Sort((x, y) => x.CategoryName.CompareTo(y.CategoryName)); CategoryList.DataSource = info; CategoryList.DataTextField = nameof(Category.CategoryName); CategoryList.DataValueField = nameof(Category.CategoryID); CategoryList.DataBind(); CategoryList.Items.Insert(0, "select..."); } catch (Exception ex) { //using the specialized error handling DataList control errormsgs.Add(GetInnerException(ex).ToString()); LoadMessageDisplay(errormsgs, "alert alert-danger"); } }
protected void Page_Load(object sender, EventArgs e) { //clear old messages MessageLabel.Text = ""; //the dropdownlist (ddl) control will be loaded // with data from the database //consideration needs to be given to the data as // it changes frequently //if your data does not change frequently then you // can consider loading on page load if (!Page.IsPostBack) { //use user friendly error handling try { //create and connect to the appropriate BLL class CategoryController sysmgr = new CategoryController(); //issue the request to the appropriate BLL class method // and capture results List <Category> datainfo = sysmgr.Category_List(); //optionally: sort the results datainfo.Sort((x, y) => x.CategoryName.CompareTo(y.CategoryName)); //attach data source collection to ddl CategoryList.DataSource = datainfo; //set the ddl DataTextField and DataValueField properties CategoryList.DataTextField = nameof(Category.CategoryName); CategoryList.DataValueField = "CategoryID"; //physically bind the data to the ddl control CategoryList.DataBind(); //optionally: add a prompt to the ddl control CategoryList.Items.Insert(0, "select ..."); } catch (Exception ex) { MessageLabel.Text = ex.Message; } } }
protected void Page_Load(object sender, EventArgs e) { //clear out old messages MessageLabel.Text = ""; //load the dropdownlist DDL with a sorted list of the categories //this load will be done once when the page 1st is loaded if (Page.IsPostBack) { //user friendly errror handling try { //the data collection will come from the database //create and connect to the appropriate BLL class CategoryController sysmgr = new CategoryController(); // the issue a request for data from the appropriate BLL class method List <Category> datainfo = sysmgr.Category_List(); //sort the collection(List<t>) datainfo.Sort((x, y) => x.CategoryName.Compareto(y.CategoryName)); //attach the daata to the DDL control CategoryList.DataSource = datainfo; // indicate the data properties for the datatextfield and the DataValueField CategoryList.DataTextField = nameof(CategoryList.CategoryName); CategoryList.DataValueField = nameof(CategoryList.CategoryID); //physically bind the data to the DDL CategoryList.DataBind(); // optionally place a promt on the DDL CategoryList.Items.Insert(0, "select..."); } catch (Exception ex) { MessageLabel.Text = ex.Message; } } }
protected void CategoryProductList_PageIndexChanging(object sender, GridViewPageEventArgs e) { //The e parameter will supply the new page index that is requested. //You must set the grid control page index to this supplied value CategoryProductList.PageIndex = e.NewPageIndex; //You must refresh your gridview with a call to the database try { CategoryController sysmgr = new CategoryController(); List <Category> datainfo = sysmgr.Category_List(); datainfo.Sort((x, y) => x.CategoryName.CompareTo(y.CategoryName)); CategoryList.DataSource = datainfo; CategoryList.DataBind(); } catch (Exception ex) { MessageLabel.Text = ex.Message; } }
protected void BindCategoryList() { try { CategoryController sysmgr = new CategoryController(); List <Category> info = null; info = sysmgr.List(); info.Sort((x, y) => x.CategoryName.CompareTo(y.CategoryName)); CategoryList.DataSource = info; CategoryList.DataTextField = nameof(Category.CategoryName); CategoryList.DataValueField = nameof(Category.CategoryID); CategoryList.DataBind(); ListItem myitem = new ListItem(); myitem.Value = "0"; myitem.Text = "select..."; CategoryList.Items.Insert(0, myitem); //CategoryList.Items.Insert(0, "select..."); } catch (Exception ex) { ShowMessage(GetInnerException(ex).ToString(), "alert alert-danger"); } }