protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) //如果是表头 { foreach (TableCell Tc in e.Row.Cells) //对每一单元格 { if (Tc.HasControls()) { if (((LinkButton)Tc.Controls[0]).CommandArgument == Label_sort.Text) { //if (((LinkButton)Tc.Controls[0]).CommandArgument == Convert.ToString(Session["sort"])) //是否为排序列 if (GridViewSortDirection == SortDirection.Ascending) //依排序方向加入方向箭头 { Tc.Controls.Add(new LiteralControl("↓")); } else { Tc.Controls.Add(new LiteralControl("↑")); } } } } } } //Grid 行初始化