2011-08-19 14 views
2

我嘗試使用SortedAscendingCellStyle分配我的GridView的風格,這是我的ASP代碼:的GridView,SortedAscendingCellStyle服務器端數據綁定

<asp:GridView ID="GridView1" runat="server" AllowSorting="True" CellPadding="4" OnSorting="GridView1_Sorting" AutoGenerateColumns="false"> 
      <SortedAscendingCellStyle CssClass="SortedAscendingCellStyle" /> 
      <SortedAscendingHeaderStyle CssClass="SortedAscendingHeaderStyle" /> 
      <SortedDescendingCellStyle CssClass="SortedDescendingCellStyle" /> 
      <SortedDescendingHeaderStyle CssClass="SortedDescendingHeaderStyle " /> 
      <Columns> 
       <asp:BoundField DataField="Nom" HeaderText="Nom" SortExpression="NOM"> 
        <ItemStyle Width="150px" /> 
       </asp:BoundField> 
       <asp:BoundField DataField="Prenom" HeaderText="Prenom"> 
        <ItemStyle Width="150px" /> 
       </asp:BoundField> 
       <asp:BoundField DataField="Pseudo" HeaderText="Pseudo"></asp:BoundField> 

       <asp:BoundField DataField="Mail" HeaderText="Mail"> 
        <ItemStyle Width="140px" /> 
       </asp:BoundField> 
      </Columns> 
     </asp:GridView> 

沒有問題,當我使用的DataSourceID,但是當我使用服務器端databining在SortedAscendingCellStyle沒有工作,這是我的代碼背後:

protected void Page_Load(object sender, EventArgs e) 
     { 
      if (!IsPostBack) 
      { 
       EmployeDAL oem = new EmployeDAL(); 
       this.GridView1.DataSource = oem.GetAll(); 
       GridView1.DataBind(); 

      } 
     } 

回答