• 03-03-2014, 21:10:42
    #1
    GridView ile veri tabanından verileri çekiyorum çektiğim müşterilerin ismini alfabatik sıralayamıyorum

    GridView in AutoSort özelliğini True yapıyorum sonra istediğim bölümün class ına SortExpression="KategoriAdi" tanımlıyorum çalıştırdığımda çalılşıyormuş gibi oluyor ama hiç bir işlem yapmıyor.

    sebebi ne olabilir? ne yapmam lazım

    kodlarım
    aspx
    <%@ Page Title="" Language="C#" MasterPageFile="~/Admin/adminmaster.master" AutoEventWireup="true" CodeFile="Musterilerilistele.aspx.cs" Inherits="Admin_Musterilerilistele" %>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
        <table border="1" cellpadding="0" cellspacing="0" width="100%">
            <tr>
                <th class="style6" height="41" scope="col" 
                    style="color: #0066FF; text-align: left; background-color: #66CCFF">
                    &nbsp;&nbsp; Müşteri Listesi</th>
            </tr>
            <tr>
                <td height="25">
                    <table border="1" cellpadding="0" cellspacing="0" width="100%">
                        <tr>
                            <th class="style3" scope="col" width="20%">
                                Müşteri Adı Soyadı</th>
                            <th class="style3" scope="col" width="20%">
                                Kategorisi</th>
                            <th class="style3" scope="col" width="20%">
                                Firma Adı</th>
                            <th class="style3" scope="col" width="20%">
                                Cep Telefonu</th>
                            <th class="style3" scope="col" width="20%">
                                İlan</th>
                            <th class="style3" scope="col" width="20%">
                                Yer Göster</th>
                            <th class="style3" scope="col" width="20%">
                                <img border="0" src="Images/edit.png" /></th>
                            <th class="style3" scope="col" width="20%">
                                <img border="0" src="../images/sil.png" /></th>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:GridView ID="dlMusteriler" runat="server" AutoGenerateColumns="False" 
                        CellPadding="4" ForeColor="#333333" GridLines="None" 
                        onrowcommand="dlMusteriler_RowCommand" Width="100%" AllowSorting="True">
                        <AlternatingRowStyle BackColor="White" />
                        <Columns>
                             <asp:BoundField HeaderStyle-HorizontalAlign="Left" DataField="MusteriAdiSoyadi" HeaderText="MusteriAdiSoyadi" 
                                SortExpression="MusteriAdiSoyadi" >
    <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
                         
                            <asp:BoundField DataField="MusteriAdiSoyadi" HeaderText="Müşteri adı" />
                            <asp:BoundField DataField="FirmaAdi" HeaderText="Firma Adı" />
                            <asp:BoundField DataField="Cep" HeaderText="Cep Telefonu" />
                            <asp:BoundField DataField="MusteriAdminAD" HeaderText="Muşteri Sorumlusu" />
                            <asp:BoundField DataField="FirmaAdi" HeaderText="Firma Adı" />
                            <asp:HyperLinkField DataNavigateUrlFields="MusteriId" 
                                DataNavigateUrlFormatString="musteriiLanGoster.aspx?id={0}" 
                                DataTextField="HaberSayisi" HeaderText="H.Sayısı" />
                            <asp:HyperLinkField DataNavigateUrlFields="MusteriId" 
                                DataNavigateUrlFormatString="musteriHaberGoster.aspx?id={0}" 
                                DataTextField="yerGostermeSayisi" HeaderText="Yer.Sayısı" />
                            <asp:HyperLinkField DataNavigateUrlFields="MusteriId" 
                                DataNavigateUrlFormatString="MusteriGuncelle.aspx?id={0}" 
                                DataTextField="MusteriId" HeaderText="Düzenle" />
                            <asp:TemplateField HeaderText="Sil">
                                <ItemTemplate>
                                    <asp:LinkButton ID="linkbuton" runat="server" 
                                        CommandArgument='<%#Eval("MusteriId") %>' Text="Sil"> </asp:LinkButton>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <EditRowStyle BackColor="#7C6F57" />
                        <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                        <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
                        <RowStyle BackColor="#E3EAEB" />
                        <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
                        <SortedAscendingCellStyle BackColor="#F8FAFA" />
                        <SortedAscendingHeaderStyle BackColor="#246B61" />
                        <SortedDescendingCellStyle BackColor="#D4DFE1" />
                        <SortedDescendingHeaderStyle BackColor="#15524A" />
                    </asp:GridView>
              
                </td>
            </tr>
        </table>
    </asp:Content>
    aspx.cs
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    
    public partial class Admin_Musterilerilistele : System.Web.UI.Page
    {
    
        public static string KategoriId = "";
        Fonksiyon system = new Fonksiyon();
        string islem = "";
        string MusteriId = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["AdminId"] == null)
            {
                Response.Redirect("Login.aspx");
            }
    
            KategoriId = Request.QueryString["KategoriId"];
            islem = Request.QueryString["islem"];
            MusteriId = Request.QueryString["MusteriId"];
    
            if (islem == "Sil")
            {
                system.cmd("Delete from Musteriler Where MusteriId=" + MusteriId);
                Response.Redirect("Musteriler.aspx");
            }
    
            DataTable dtMusteriler = system.GetDataTable("exec mustericek");
            dlMusteriler.DataSource = dtMusteriler;
            dlMusteriler.DataBind();
    
    
        }
        protected void dlMusteriler_RowCommand(object sender, GridViewCommandEventArgs e)
        {
    
            Response.Redirect("Musterilerilistele.aspx");
            system.cmd("Delete from Musteriler Where MusteriId=16");
            // Response.Redirect("Musteriler.aspx");
    
        }
      
    }
  • 04-03-2014, 16:36:09
    #2
    Kimlik doğrulama veya yönetimden onay bekliyor.
    Gridview de niye siralamaya çalışıyonuz ki. database den çekerken siralayın.

    order by MusteriAdiSoyadi asc

    ile yani yukardaki kodu mustericek fonksiyonundaki select* from blabal dan sonraya yazın
  • 04-03-2014, 21:12:08
    #3
    Kimlik doğrulama veya yönetimden onay bekliyor.
    Gridview'ın onsorting event'ı var. Orada yapabilirsiniz.
    protected void gvName_Sorting( object sender, GridViewSortEventArgs e )
    {
        // sırala ve tekrar bind et.
    }
  • 05-03-2014, 20:08:49
    #4
    rob33n adlı üyeden alıntı: mesajı görüntüle
    Gridview'ın onsorting event'ı var. Orada yapabilirsiniz.
    protected void gvName_Sorting( object sender, GridViewSortEventArgs e )
    {
        // sırala ve tekrar bind et.
    }
    hopcam dediğiniz gibi yaptığımdada farklı hata alıyorum Sadece müşteri adını bölümüne tıklanınca sıralasın yeter aslında basit olduğunu biliyorum ama yapamadım

    benim kodlarıma ekleyebilirmisiniz