protected void Page_Load(object sender, EventArgs e) { County = Convert.ToInt32(Request.QueryString["CountyId"]); Country = Convert.ToInt32(Request.QueryString["CountryId"]); if (!IsPostBack) { try { ViewState["Column"] = "DEDListId"; ViewState["Sortorder"] = "desc"; DAL.general objGen = new DAL.general(); DataSet ds1 = objGen.getdataset("select County from dbo.County where CountyId=" + County + ""); CountyName = Convert.ToString(ds1.Tables[0].Rows[0][0]); lblCounty.Text = "DED List For County " + CountyName; DataSet ds = objGen.getdataded(Country, County); Repeater1.DataSource = ds; Repeater1.DataBind(); } catch (Exception ex) { } } }
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == ViewState["Column"].ToString()) { if (ViewState["Sortorder"].ToString() == "ASC") ViewState["Sortorder"] = "DESC"; else ViewState["Sortorder"] = "ASC"; } else { ViewState["Column"] = e.CommandName; ViewState["Sortorder"] = "ASC"; } DAL.general objGen = new DAL.general(); DataSet ds = objGen.getdataded(Country, County); DataView dvData = new DataView(ds.Tables[0]); dvData.Sort = ViewState["Column"] + " " + ViewState["Sortorder"]; Repeater1.DataSource = dvData; Repeater1.DataBind(); }