예제 #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         GridViewMusteriListesi.DataSource = MusteriListesi;
         GridViewMusteriListesi.DataBind();
     }
 }
예제 #2
0
    protected void GridViewMusteriListesi_Sorting(object sender, GridViewSortEventArgs e)
    {
        if ((ViewState["SortExpression"] != null) && (ViewState["SortExpression"].ToString() != e.SortExpression))
        {
            ViewState["SortExpression"] = e.SortExpression;
        }
        else
        {
            if (ViewState["SortDirection"] != null)
            {
                e.SortDirection = (SortDirection)ViewState["SortDirection"];
            }
        }


        List <Musteri>        liste = MusteriListesi;
        IEnumerable <Musteri> sonuc = null;

        if (e.SortExpression == "Adi" && e.SortDirection == SortDirection.Ascending)
        {
            sonuc = from musteri in liste
                    orderby musteri.Adi ascending
                    select musteri;
            ViewState["SortDirection"] = SortDirection.Descending;
        }
        else if (e.SortExpression == "Adi" && e.SortDirection == SortDirection.Descending)
        {
            sonuc = from musteri in liste
                    orderby musteri.Adi descending
                    select musteri;
            ViewState["SortDirection"] = SortDirection.Ascending;
        }
        if (sonuc != null)
        {
            List <Musteri> sortedListe = (List <Musteri>)sonuc.ToList();
            GridViewMusteriListesi.DataSource = sortedListe;
            GridViewMusteriListesi.DataBind();
        }
    }