ASP实现的一个DataGrid类α版[2]

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 redv 的 blog

  dg.tableattribute = "cellspacing=""0"" rules=""all"" border=""1"" style=""border-collapse:collapse;"""
  '设置表格头属性
  dg.thattribute = "bgcolor=""#eeeeee"" style=""font:normal"""
  '设置表行属性
  dg.trattribute = "onmouseover=""this.style.backgroundcolor='#efefef'"" onmouseout=""this.style.backgroundcolor=''"""
  '设置数据源,为一二维数组
  dg.datasource = rows
  '设置行数,默认为数据源的行数
  if isarray(rows) then
    dg.rowcount = ubound(rows)
  else
    dg.rowcount = 0
  end if
  '列数,默认为columns属性的长度
  dg.columncount = 6
  '设置列绑定
  dg.columns = array( _
                      "<input type=""checkbox"" name=""id"" value=""{text[0]}"">", _
                      "{text[0]}", _
                      "{html[2]}", _
                      "{text[4]}", _
                      "{text[3]}", _
                      "<a href=""edit.asp?id={text[0]}"">编辑</a>"_
                    )
  'response.write(rows(0)(1))
  '设置列宽度
  dg.columnwidths = array("5%","5%", "20%", "30%", "20%", "")
  '设置列文字对齐方式
  dg.columnaligns = array("center", "center", "center", "center", "center", "center")
  '设置表头文字,支持html格式
  ''请把下面的汉字修改成类似:lan_gettext(languageid,32)
  dg.headertexts = array("<input type=""checkbox"" onclick=""selectall(this)"">", "id", "新闻标题", "新闻摘要", "输入时间", "操作")
  '设置表头文字对齐属性,默认对齐方式为center
  dg.headertextaligns = array("center", "center", "center", "center", "center", "center")
 
  ret = ret & dg.totable()
  ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  ret = ret & "<input type=""submit"" value=""删除"">"
 
  ret = ret & "</form>"
  res.write(ret)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 
end function

'
'@param rowcount 总行数
'@param pagesize 每页显示的行数
'@param page_param_name page的参数名,用在querystring中
'@param currentpage 当前页码
'@return 分页字符串
public function page(pagestringtemplate, pagestringtemplate0, pagestringtemplateprevious0, pagestringtemplatenext0, pagestringtemplateprevious1, pagestringtemplatenext1, rowcount, pagesize, page_param_name, currentpage)
  rowcount = cint(rowcount)
  pagesize = cint(pagesize)
  currentpage = cint(currentpage)
  dim ret
  dim pagecount, i, tmp
  tmp = rowcount / pagesize
  pagecount = fix(tmp)
  if(tmp > pagecount) then
    pagecount = pagecount + 1
  end if
  dim p1, p2
  p1 = ""
  'p1 = p1 &  "合计<font color=""red"">" & rowcount & "</font>条记录" _
  '   & "第<font color=""red"">" & currentpage & "</font>页/" _
  '   & "合计<font color=""red"">" & pagecount & "</font>页"
  p1 = pagestringtemplate0
  p1 = replace(p1, "{rowcount}", rowcount)
  p1 = replace(p1, "{currentpage}", currentpage)
  p1 = replace(p1, "{pagecount}", pagecount)
  ''''''''''''''''''''
  ''''''''''''''''''''
 
  if currentpage > 1 then
    'p2 = p2 & "<a href=""?" & page_param_name & "=" & (currentpage-1) & """>" & "上一页" & "</a>&nbsp;"
    p2 = p2 & replace(pagestringtemplateprevious1, "{previous}", currentpage -1)
  else
    'p2 = p2 & "上一页&nbsp;"
    p2 = p2 & pagestringtemplateprevious0
  end if
  for i = 1 to pagecount
    if i = currentpage then

本文关键:ASP实现的一个DataGrid类α版
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top