2016-12-30 14 views
1

グリッドビューをソートしています。ソートが完璧です。ソート矢印を各ヘッダーの列の隣に追加しようとしています。矢印はほとんどあらゆる方法で試しましたが、矢印は表示されません私UI.PFBに表示される自分のコード:グリッドビューソート矢印が表示されない

CSS:

th .ascending a { 
    background: url(images/ascArrow.gif) no-repeat; 
    display: block; 
    padding: 0 4px 0 15px; 
} 

th .descending a { 
    background: url(images/descArrow.gif) no-repeat; 
    display: block; 
    padding: 0 4px 0 15px; 
} 

背後にあるコード:

protected void RPMData_Sorting(object sender, GridViewSortEventArgs e) 
    { 
     if (TextData.Text == String.Empty) 
     { 
      SqlCommand cmd = new SqlCommand("select Customer_Name,Site_Type,Source,Destination,Latency,Jitter_Priority_Real_Time,Jitter_Real_Time,PacketLoss_Priority_Real_Time,PacketLoss_Real_Time,PacketLoss_Other_Classes from RPM", con); 
      con.Open(); 
      SqlDataAdapter da = new SqlDataAdapter(cmd); 
      da.Fill(dt1); 
      con.Close(); 
      if (dt1.Rows.Count > 0) 
      { 
       string sortingDirection = string.Empty; 
       if (direction == SortDirection.Ascending) 
       { 
        direction = SortDirection.Descending; 
        RPMData.HeaderStyle.CssClass = "descending"; 
        sortingDirection = "Desc"; 
       } 
       else 
       { 
        direction = SortDirection.Ascending; 
        RPMData.HeaderStyle.CssClass = "ascending"; 
        sortingDirection = "Asc"; 
       } 

       DataView sortedView = new DataView(dt1); 
       sortedView.Sort = e.SortExpression + " " + sortingDirection; 
       Session["SortedView"] = sortedView; 
       RPMData.DataSource = sortedView; 
       RPMData.DataBind(); 
      } 
     } 

//ソートロジックは、フィルタapplied.Iに基づいて2つの条件が追加されているましたここでの唯一の最初の条件

GridViewのタグ:

<asp:GridView CssClass="infoTable" ID="RPMData" runat="server" OnSelectedIndexChanged="Button1_Click" AllowPaging="True" PageSize="10" OnPageIndexChanging="RPMData_PageIndexChanging" AllowSorting="True" OnSorting="RPMData_Sorting" AutoGenerateColumns="False" SortedAscendingHeaderStyle-CssClass="ascending" SortedDescendingHeaderStyle-CssClass="descending"> 
    <HeaderStyle CssClass="ascending" /> 
     <Columns> 

は私を助けてください。

答えて

0

HeaderStyle.CssClassは、encyreヘッダー行<tr class="ascending">に適用され、idividual thセルには適用されません。

<style> 
    .ascending a { 
     background:url(images/ascArrow.gif) no-repeat; 
     display: block; 
     padding: 0 4px 0 15px; 
    } 

    .descending a { 
     background:url(images/descArrow.gif) no-repeat; 
     display: block; 
     padding: 0 4px 0 15px; 
    } 
</style> 

にあなたのCSSを変更したり、あなたが他の場所で、そのクラスを使用する場合、.ascending th aは、それが唯一のヘッダー行に影響を保証します。

関連する問題