在Gridview中排序如果templatefield有表,则不起作用 [英] Sorting in Gridview Not working if templatefield has table

查看:110
本文介绍了在Gridview中排序如果templatefield有表,则不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我的网格视图如下html标签

Hi ,

I am having gridview as below html tag

<asp:gridview id="grdView" runat="server" onsorting="grdView_Sorting" allowsorting="true">
 <columns>
<asp:TemplateField SortExpression="CategoryCode">
<HeaderTemplate>
<table width="730px" border="1">
 <tr>
<td>
---- I have some header names inside this td's
</td>
</tr>
</table>
</HeaderTemplate>
 <itemtemplate>
<table border="0" class="displaygrid" width="730px">
<tr>
<td>
<div>
 <%# Eval("Description")%>
</div>

</td>
<td>
<div>
 <%# Eval("CategoryCode")%>
</div>
</td>
</tr>
</table>
</itemtemplate></columns>



如果我有设计,排序不会以这种方式运作,请任何人都可以帮助我。


Sorting is not working in this way if i have designed ,please can anyone help me.

推荐答案

您可以尝试下面的内容(这是示例代码):



改变了这个:



You could try something like below (this is a sample code):

Changed this :

<asp:TemplateField SortExpression="Category">
   <HeaderTemplate>Category</HeaderTemplate>
   <ItemTemplate>A value</ItemTemplate>
</asp:TemplateField>





至此:





To This :

<asp:TemplateField HeaderText="Category" SortExpression="Category">
   <ItemTemplate>A value</ItemTemplate>
</asp:TemplateField>







删除了 HeaderTemplate 并添加了 HeaderText TemplateField



欲了解更多信息: http://stackoverflow.com/questions/1597977/gridview-sorting-with-custom-template-fields [ ^ ]



关于如何使用网格视图处理模板字段的完整文章:



http://www.asp.net/web-forms/tutorials/data-access/custom-格式化/使用templatefields-in-the gridview-control-cs [ ^ ]



我希望这会对你有所帮助。




Removed the HeaderTemplate and added the HeaderText in the TemplateField.

For more info : http://stackoverflow.com/questions/1597977/gridview-sorting-with-custom-template-fields[^]

Complete article about How to handle Template fields with Grid view :

http://www.asp.net/web-forms/tutorials/data-access/custom-formatting/using-templatefields-in-the-gridview-control-cs[^]

I hope this will help to you.


这篇关于在Gridview中排序如果templatefield有表,则不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆