Default.aspx.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. public partial class _Default : System.Web.UI.Page
  9. {
  10. protected void Page_Load(object sender, EventArgs e)
  11. {
  12. DataTable dt = testTable();
  13. List<string> colPerWidth=new List<string>();
  14. for (int i = 0; i < 10; i++)
  15. {
  16. colPerWidth.Add("150");
  17. }
  18. ScrollerTable table = new ScrollerTable();
  19. string html= table.GetScrollerTable(dt,1, colPerWidth,1000,600);
  20. divTable.InnerHtml = html;
  21. }
  22. private DataTable testTable()
  23. {
  24. int colsCount = 10;
  25. int rowsCount = 40;
  26. DataTable dt =new DataTable();
  27. for (int i = 0; i < colsCount; i++)
  28. {
  29. dt.Columns.Add("表头" + i);
  30. }
  31. for (int i = 0; i < rowsCount; i++)
  32. {
  33. DataRow row = dt.NewRow();
  34. for (int j = 0; j < colsCount; j++)
  35. {
  36. row[j] = "第"+i+"行,内容" + j;
  37. }
  38. dt.Rows.Add(row);
  39. }
  40. return dt;
  41. }
  42. }