我正在对网格进行排序view.The排序工作perfect.Now我正在尝试将排序箭头添加到每个标题列旁边。我尝试了几乎所有的方法,但箭头不显示在我的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();
}
}//根据应用的过滤器,排序逻辑有两个条件。我在这里只添加了第一个条件
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>请帮帮我。
https://stackoverflow.com/questions/41390519
复制相似问题