JQuery遍历Gridview JQuery遍历GridView各个数据,如果长度大于8,8位后的数据用...来显示~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectDataSource1" DataKeyNames="id" CellPadding="4" ForeColor="#333333" GridLines="None" AllowSorting="True" AllowPaging="true" PageSize="2" EnableSortingAndPagingCallbacks="True" onrowdatabound="GridView1_RowDataBound"> <PagerSettings Mode="Numeric" /> <AlternatingRowStyle BackColor="White" /> <Columns> <asp:BoundField DataField="id" HeaderText="Id" ReadOnly="true" SortExpression="id" ShowHeader="true" /> <asp:BoundField DataField="poly1" HeaderText="poly1" SortExpression="poly1" ShowHeader="true" /> <asp:BoundField DataField="poly2" HeaderText="poly2" SortExpression="poly2" ShowHeader="true" /> <asp:BoundField DataField="polyresult" HeaderText="polyresult" SortExpression="polyresult" ShowHeader="true" /> <asp:BoundField DataField="time" HeaderText="Time" SortExpression="Time" ShowHeader="true" /> <asp:CommandField ShowDeleteButton="True" /> </Columns> <EditRowStyle BackColor="#2461BF" /> <EmptyDataTemplate> <div style="text-align: center;"> No data </div> </EmptyDataTemplate> <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" /> <RowStyle BackColor="#EFF3FB" /> <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" /> <SortedAscendingCellStyle BackColor="#F5F7FB" /> <SortedAscendingHeaderStyle BackColor="#6D95E1" /> <SortedDescendingCellStyle BackColor="#E9EBEF" /> <SortedDescendingHeaderStyle BackColor="#4870BE" /> </asp:GridView>在调整浏览器的时候用JQuery判断,如果长度大于8,8位后的数据用...来显示~ var GridView1 = document.getElementById("<%=GridView1.ClientID %>"); for(i=1;i<GridView1.rows.length; i++) { var a=GridView1.rows[i].cells[0].getElementsByTagName("INPUT")[2]; } <!--用了table代替测试,和gridview一样,gridview最后也是生成table--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head> <title>无标题页</title> <script type="text/javascript" src="jquery-1.3.2.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(window).resize(function(){ $("#gridview td").each(function(){ if($(this).html().length>8){ $(this).html($(this).html().substr(0,8)+"..."); } }) }) }) </script></head><body><table id="gridview"> <tr> <td>123456789</td> </tr> <tr> <td>123456789</td> </tr> <tr> <td>123456789</td> </tr> <tr> <td>123456789</td> </tr></table></body></html> 关注下。 有个第三方控件可以做--dev 1:你可以给每个td加个一样的空样式然后遍历gridview下的样式2:也可以选择过滤掉你分页的td,这个要看生成的html代码是怎么样的! 还是GirdView的问题 timestamp 取出来怎么存 有没有这样的grid控件? 小型公司网站 请问如何在自定义控件中加属性? Server.Transfer的一点疑惑 NET读取WORD表格中行列数出错,高分求救。 自己写的Adapter模式的一个范例,供初学者学习 怎么统计用户登出的时间 关于释放sql server 2000连接的问题! MVC如何实现在不同页面之间传值? session 跳过过期时间直接关闭的方法
DataKeyNames="id" CellPadding="4" ForeColor="#333333" GridLines="None" AllowSorting="True"
AllowPaging="true" PageSize="2" EnableSortingAndPagingCallbacks="True"
onrowdatabound="GridView1_RowDataBound">
<PagerSettings Mode="Numeric" />
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="id" HeaderText="Id" ReadOnly="true" SortExpression="id"
ShowHeader="true" />
<asp:BoundField DataField="poly1" HeaderText="poly1" SortExpression="poly1" ShowHeader="true" />
<asp:BoundField DataField="poly2" HeaderText="poly2" SortExpression="poly2" ShowHeader="true" />
<asp:BoundField DataField="polyresult" HeaderText="polyresult" SortExpression="polyresult"
ShowHeader="true" />
<asp:BoundField DataField="time" HeaderText="Time" SortExpression="Time" ShowHeader="true" />
<asp:CommandField ShowDeleteButton="True" />
</Columns>
<EditRowStyle BackColor="#2461BF" />
<EmptyDataTemplate>
<div style="text-align: center;">
No data
</div>
</EmptyDataTemplate>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
在调整浏览器的时候用JQuery判断,如果长度大于8,8位后的数据用...来显示~
for(i=1;i<GridView1.rows.length; i++)
{
var a=GridView1.rows[i].cells[0].getElementsByTagName("INPUT")[2]; }
<!--用了table代替测试,和gridview一样,gridview最后也是生成table-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>无标题页</title>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(window).resize(function(){
$("#gridview td").each(function(){
if($(this).html().length>8){
$(this).html($(this).html().substr(0,8)+"...");
}
})
})
})
</script>
</head>
<body>
<table id="gridview">
<tr>
<td>123456789</td>
</tr>
<tr>
<td>123456789</td>
</tr>
<tr>
<td>123456789</td>
</tr>
<tr>
<td>123456789</td>
</tr>
</table>
</body>
</html>
然后遍历gridview下的样式
2:也可以选择过滤掉你分页的td,这个要看生成的html代码是怎么样的!