private void FillFilters(SimcardFilter sf) { ((TextBox)gvSimcards.HeaderRow.FindControl("txtSimnumber")).Text = sf.SimnumberFilter; ((TextBox)gvSimcards.HeaderRow.FindControl("txtNumber")).Text = sf.NumberFilter; ((DropDownList)gvSimcards.HeaderRow.FindControl("ddlType")).SelectedValue = sf.TypeFilter; ((TextBox)gvSimcards.HeaderRow.FindControl("txtProvider")).Text = sf.ProviderFilter; ((DropDownList)gvSimcards.HeaderRow.FindControl("ddlUnit")).SelectedValue = sf.UnitFilter; ((DropDownList)gvSimcards.HeaderRow.FindControl("ddlStatus")).SelectedValue = sf.StatusFilter; ((DropDownList)gvSimcards.HeaderRow.FindControl("ddlTaxType")).SelectedValue = sf.TaxTypeFilter; ((TextBox)gvSimcards.HeaderRow.FindControl("txtEmployee")).Text = sf.EmployeeFilter; }
protected void gvSimcards_DataBound(object sender, EventArgs e) { SimcardFilter sf = ViewState["sf"] as SimcardFilter ?? new SimcardFilter(); FillFilters(sf); if (gvSimcards.PageCount > 1) { int maxcount = gvSimcards.PageCount * gvSimcards.PageSize; int mincount = maxcount - gvSimcards.PageSize; lblRowCount.Text = $"{mincount}-{maxcount} resultater"; } else { int count = gvSimcards.Rows.Count; lblRowCount.Text = $"{count} resultat{(count != 1 ? "er" : "")}"; } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { SimcardFilter sf = GetFilledSimcardFilter(); sdsSimcards.FilterParameters["@Simnumber"].DefaultValue = sf.SimnumberFilter; sdsSimcards.FilterParameters["@Number"].DefaultValue = sf.NumberFilter; sdsSimcards.FilterParameters["@Type"].DefaultValue = sf.TypeFilter; sdsSimcards.FilterParameters["@Provider"].DefaultValue = sf.ProviderFilter; sdsSimcards.FilterParameters["@Unit"].DefaultValue = sf.UnitFilter; sdsSimcards.FilterParameters["@Status"].DefaultValue = sf.StatusFilter; sdsSimcards.FilterParameters["@TaxType"].DefaultValue = sf.TaxTypeFilter; sdsSimcards.FilterParameters["@Employee"].DefaultValue = sf.EmployeeFilter; gvSimcards.DataBind(); FillFilters(sf); } }