protected void btnSave_Command(object sender, System.Web.UI.WebControls.CommandEventArgs e) { if (e.CommandName == "Save") { displayValues = (List <CSBusiness.Country>)ViewState["Items"]; if (displayValues.Count > 0) { List <CSBusiness.Country> MasterList = CountryManager.GetAllMasterCountries(); foreach (CSBusiness.Country item in displayValues) { CSBusiness.Country existItem = MasterList.FirstOrDefault(x => x.CountryId == item.CountryId); if (existItem != null) { item.Code = existItem.Code; item.OrderNo = existItem.OrderNo; } } CountryManager.CreateCountry(displayValues); CountryManager.ResetCountryCache(); } } Response.Redirect("CountryList.aspx"); }
protected void dlrepeater_ItemCommand(object sender, RepeaterCommandEventArgs e) { switch (e.CommandName) { case "Delete": displayValues = (List <CSBusiness.Country>)ViewState["Items"]; CSBusiness.Country item = displayValues.FirstOrDefault(x => x.CountryId == Convert.ToInt32(e.CommandArgument)); displayValues.Remove(item); BindItem(); break; } }
protected void btn_AddCountry(object sender, EventArgs e) { displayValues = (List <CSBusiness.Country>)ViewState["Items"]; int countryId = Convert.ToInt32(ddlProducts.SelectedItem.Value); string countryName = ddlProducts.SelectedItem.Text; CSBusiness.Country item = displayValues.FirstOrDefault(x => x.CountryId == countryId); if (item == null) { displayValues.Add(new CSBusiness.Country(countryId, countryName)); } BindItem(); }
protected void dlCountryList_ItemDataBound(object sender, DataListItemEventArgs e) { CSBusiness.Country countryItem = e.Item.DataItem as CSBusiness.Country; if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { ITextControl lblTitle = e.Item.FindControl("lblTitle") as ITextControl; CheckBox cbVisible = e.Item.FindControl("cbVisible") as CheckBox; TextBox txtOrderNo = e.Item.FindControl("txtOrderNo") as TextBox; HyperLink hlLikn = e.Item.FindControl("hlAddState") as HyperLink; lblTitle.Text = countryItem.Name; cbVisible.Checked = countryItem.Visible; txtOrderNo.Text = countryItem.OrderNo.ToString(); hlLikn.NavigateUrl = "State.aspx?Id=" + countryItem.CountryId; } }
protected void BindCounty() { List <CSBusiness.Country> MasterList = CountryManager.GetAllMasterCountries(); CountryCache cache = new CountryCache(this.Context); List <CSBusiness.Country> list = (List <CSBusiness.Country>)cache.Value; foreach (CSBusiness.Country item in list) { CSBusiness.Country existItem = MasterList.FirstOrDefault(x => x.CountryId == item.CountryId); if (existItem != null) { MasterList.Remove(existItem); } } ddlProducts.DataSource = MasterList; ddlProducts.DataTextField = "Name"; ddlProducts.DataValueField = "CountryId"; ddlProducts.DataBind(); ddlProducts.Items.Insert(0, new ListItem("Select", "")); }