允许在asp c#代码中生成表中的分页 [英] allow paging in generated table in asp c# code
本文介绍了允许在asp c#代码中生成表中的分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我使用c#代码创建html表生成表
现在我如何允许分页到我的表?
我的代码是
Hi
I create html table using c# code to generate table
Now how can i allow paging to my table ?
My code is
html.Append("<table border="1">");
int itemCount = 0;
StringBuilder sbImageRow = new StringBuilder();
StringBuilder sbNameRow = new StringBuilder();
foreach (DataRow row in dt.Rows)
{
itemCount++;
int windex = row["Image"].ToString().IndexOf("/");
sbImageRow.Append("<td><img src='" + row["Image"].ToString().Substring(windex) + "' height='60' width='60' </></td>");
sbNameRow.Append("<td>" + row["Name"] + "</td>");
if(itemCount % 3 == 0)
{
//Add Image Row
html.Append("<tr>");
html.Append(sbImageRow.ToString());
html.Append("</tr>");
//Add Name Row
html.Append("<tr>");
html.Append(sbNameRow.ToString());
html.Append("</tr>");
//Reset values for next group
itemCount = 0;
sbImageRow = new StringBuilder();
sbNameRow = new StringBuilder();
}
}
//Check if some of the data hasn't been added to table yet
if(itemCount != 0)
{
//Pad with empty cells if needed
for(int i = itemCount; i < 3; i++)
{
sbImageRow.Append("<td></td>");
sbNameRow.Append("<td></td>");
}
//Add Image Row
html.Append("<tr>");
html.Append(sbImageRow.ToString());
html.Append("</tr>");
//Add Name Row
html.Append("<tr>");
html.Append(sbNameRow.ToString());
html.Append("</tr>");
}
html.Append("</table>");
推荐答案
查看这些文章。
客户端分页表 [ ^ ]
使用JavaScript的客户端HTML表格分页
Have a look at these articles.
Client-Side Paging with Tables[^]
Client-side HTML table pagination with JavaScript
这篇关于允许在asp c#代码中生成表中的分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文