我有一个asp:GridView控件,我已经设置了AllowSorting="True"属性:
<asp:GridView ID="gridUsers" runat="server" PageSize="100" ShowHeaderWhenEmpty="True"
Width="100%" AllowSorting="True" onrowcreated="gridUsers_RowCreated"
onsorting="gridUsers_Sorting">
</asp:GridView>
Run Code Online (Sandbox Code Playgroud)
在设计时,网格看起来是可排序的:

但在运行时只有中间列是可排序的:

如何asp:GridView在ASP.NET中进行排序?
注意:asp:GridViewwith AllowSorting 需要存在Sorting事件处理程序:
protected void gridUsers_Sorting(object sender, GridViewSortEventArgs e)
{
//asp:GridView will throw an exception if a Sorting event handler isn't present
}
Run Code Online (Sandbox Code Playgroud)
更新:我意识到Description列的特殊之处.它是唯一一个按原样从数据库中显示名称正确的列.剩下的列我必须修改显示名称才能显示:
protected void gridUsers_RowCreated(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[0].Visible = false; //UserGUID
e.Row.Cells[1].Text = "User name";
e.Row.Cells[2].Text = "Full name";
//3=Description
e.Row.Cells[4].Text = "E-mail"; …Run Code Online (Sandbox Code Playgroud) 有人可以使用javascript显示/隐藏跨度的方法吗
document.getElementById("test").style.display= 'visible';
document.getElementById("test").style.display= 'block';
Run Code Online (Sandbox Code Playgroud)
在HTML代码中
<span id='test' ..
Run Code Online (Sandbox Code Playgroud)
我该如何克服这个问题。有什么我应该考虑的吗?
更新 我有一个像这样的类,我想强迫鼠标悬停在它上面。
<div id="test" class="tooltip effect">
<div id="second" href="#"> .. </div>
Run Code Online (Sandbox Code Playgroud)
在CSS上:
tooltip{..}
effect{..}
effect:hover{..}
Run Code Online (Sandbox Code Playgroud)
除了您的代码,我尝试过的另一种选择是
document.getElementById("test").onmouseover = test.hover;
Run Code Online (Sandbox Code Playgroud)