protected void gridMain_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { int recSkip = gridMain.CurrentPageIndex * gridMain.PageSize; int recTake = gridMain.PageSize; try { CustomerTypesController cont = new CustomerTypesController(); gridMain.VirtualItemCount = cont.CountCustomerTypes(); gridMain.DataSource = cont.GetCustomerTypes(recSkip, recTake); } catch (Exception) { } }
protected void gridMain_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridFilteringItem) { GridFilteringItem filterItem = (GridFilteringItem)e.Item; RadDropDownList cflist = (RadDropDownList)filterItem.FindControl("ddlCountryFilter"); RadDropDownList ctflist = (RadDropDownList)filterItem.FindControl("ddlCustomerTypeFilter"); RadDropDownList lflist = (RadDropDownList)filterItem.FindControl("ddlLanguageFilter"); RadDropDownList uflist = (RadDropDownList)filterItem.FindControl("ddlUserFilter"); try { CountriesController ccont = new CountriesController(); cflist.DataSource = ccont.GetCountries(); cflist.DataTextField = "NameGR"; cflist.DataValueField = "ID"; cflist.DataBind(); cflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0")); CustomerTypesController ctcont = new CustomerTypesController(); ctflist.DataSource = ctcont.GetCustomerTypes(); ctflist.DataTextField = "NameGR"; ctflist.DataValueField = "ID"; ctflist.DataBind(); ctflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0")); LanguagesController lcont = new LanguagesController(); lflist.DataSource = lcont.GetLanguages(); lflist.DataTextField = "Name"; lflist.DataValueField = "ID"; lflist.DataBind(); lflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0")); UsersController ucont = new UsersController(); uflist.DataSource = ucont.GetUsers(); uflist.DataTextField = "NameGR"; uflist.DataValueField = "ID"; uflist.DataBind(); uflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0")); } catch (Exception) { } } }
protected void gridMain_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridEditableItem && e.Item.IsInEditMode) { countryID = -1; Session.Remove("CountryID"); customerTypeID = -1; Session.Remove("CustomerTypeID"); languageID = -1; Session.Remove("LanguageID"); userID = -1; Session.Remove("UserID"); GridEditableItem item = e.Item as GridEditableItem; RadDropDownList ddlCountries = item.FindControl("ddlCountries") as RadDropDownList; RadDropDownList ddlCustomerTypes = item.FindControl("ddlCustomerTypes") as RadDropDownList; RadDropDownList ddlLanguages = item.FindControl("ddlLanguages") as RadDropDownList; RadDropDownList ddlUsers = item.FindControl("ddlUsers") as RadDropDownList; try { CustomerB currCustomer = e.Item.DataItem as CustomerB; CountriesController countriesCont = new CountriesController(); ddlCountries.DataSource = countriesCont.GetCountries(); ddlCountries.DataTextField = "NameGR"; ddlCountries.DataValueField = "ID"; ddlCountries.DataBind(); if (currCustomer != null) { ddlCountries.SelectedIndex = ddlCountries.FindItemByValue(currCustomer.CountryID.ToString()).Index; Session["CountryID"] = currCustomer.CountryID; } else { ddlCountries.SelectedIndex = ddlCountries.FindItemByValue("1").Index;; Session["CountryID"] = ddlCountries.SelectedItem.Value; } CustomerTypesController customerTypesCont = new CustomerTypesController(); ddlCustomerTypes.DataSource = customerTypesCont.GetCustomerTypes(); ddlCustomerTypes.DataTextField = "NameGR"; ddlCustomerTypes.DataValueField = "ID"; ddlCustomerTypes.DataBind(); if (currCustomer != null) { ddlCustomerTypes.SelectedIndex = ddlCustomerTypes.FindItemByValue(currCustomer.CustomerTypeID.ToString()).Index; Session["CustomerTypeID"] = currCustomer.CustomerTypeID; } else { ddlCustomerTypes.SelectedIndex = 0; Session["CustomerTypeID"] = ddlCustomerTypes.SelectedItem.Value; } LanguagesController languagesCont = new LanguagesController(); ddlLanguages.DataSource = languagesCont.GetLanguages(); ddlLanguages.DataTextField = "Name"; ddlLanguages.DataValueField = "ID"; ddlLanguages.DataBind(); if (currCustomer != null) { ddlLanguages.SelectedIndex = ddlLanguages.FindItemByValue(currCustomer.LanguageID.ToString()).Index; Session["LanguageID"] = currCustomer.LanguageID; } else { ddlLanguages.SelectedIndex = ddlLanguages.FindItemByValue("1").Index; Session["LanguageID"] = ddlLanguages.SelectedItem.Value; } UsersController usersCont = new UsersController(); ddlUsers.DataSource = usersCont.GetUsers(); ddlUsers.DataTextField = "NameGR"; ddlUsers.DataValueField = "ID"; ddlUsers.DataBind(); if (currCustomer != null) { ddlUsers.SelectedIndex = ddlUsers.FindItemByValue(currCustomer.UserID.ToString()).Index; Session["UserID"] = currCustomer.UserID; } else { ddlUsers.SelectedIndex = 0; Session["UserID"] = ddlUsers.SelectedItem.Value; } } catch (Exception) { } } if (e.Item is GridFilteringItem) { GridFilteringItem filterItem = (GridFilteringItem)e.Item; RadDropDownList cflist = (RadDropDownList)filterItem.FindControl("ddlCountryFilter"); RadDropDownList ctflist = (RadDropDownList)filterItem.FindControl("ddlCustomerTypeFilter"); RadDropDownList lflist = (RadDropDownList)filterItem.FindControl("ddlLanguageFilter"); RadDropDownList uflist = (RadDropDownList)filterItem.FindControl("ddlUserFilter"); try { CountriesController ccont = new CountriesController(); cflist.DataSource = ccont.GetCountries(); cflist.DataTextField = "NameGR"; cflist.DataValueField = "ID"; cflist.DataBind(); cflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0")); CustomerTypesController ctcont = new CustomerTypesController(); ctflist.DataSource = ctcont.GetCustomerTypes(); ctflist.DataTextField = "NameGR"; ctflist.DataValueField = "ID"; ctflist.DataBind(); ctflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0")); LanguagesController lcont = new LanguagesController(); lflist.DataSource = lcont.GetLanguages(); lflist.DataTextField = "Name"; lflist.DataValueField = "ID"; lflist.DataBind(); lflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0")); UsersController ucont = new UsersController(); uflist.DataSource = ucont.GetUsers(); uflist.DataTextField = "NameGR"; uflist.DataValueField = "ID"; uflist.DataBind(); uflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0")); } catch (Exception) { } } }