![]() | Next:从数据表中取出第n条到第m条的记录的方法 |
DataGrid控件
2005-5-14 12:08:00 [ Author: hubro | Web&Program ]
Font Size: Big Middle Small
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script> name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-2574632228537424&dt=1164818953234&lmt=1163047541&format=728x90_as&output=html&url=http%3A%2F%2Fwww.hubro.net%2Fitem%2F82%2F&color_bg=FFFFFF&color_text=333333&color_link=cc0000&color_url=666666&color_border=FFFFFF&ad_type=text_image&ref=http%3A%2F%2Fwww.google.com%2Fsearch%3Fhl%3Dzh-CN%26newwindow%3D1%26q%3D.net%2B%2B%2Bcheckbox%25E7%259A%2584datagrid%25E6%258E%25A7%25E4%25BB%25B6%26lr%3D&cc=100&u_h=800&u_w=1280&u_ah=772&u_aw=1280&u_cd=32&u_tz=480" frameborder="0" width="728" scrolling="no" height="90" allowtransparency="allowtransparency"> 有了它,可以方便对表中的记录进行修改,删除
必须有自动编号ID
必须用到我的命名空间article
我就不用我的表演示了,上传了一个图片
修改时间:2005-9-1
修改内容:
修改了自动从字段设置标题头,不批定显示的字段时按表中的所有字段显示
属性:
sql:SQL语句,如 sql="select * from tabel"
cells:要显示的字段名,如cells="username,addtime"
pagesize:每页记录数
edit:是否编辑,true,false
del:是否有删除,true,false
headtext:相应字段的名称,如headtext="用户名,密码"
使用
<%@ Register TagPrefix="thefile" Namespace="MyDataGrid" Assembly="DataGrid" %>
<form runat="server">
<thefile:Grid sql="select * from comment" cells="username,addtime" pagesize=20 edit=true runat=server />
</form>
详细代码
生成控件确实是件麻烦事,好多方法不能用
看这里
/*
TemplateColumn tm=new TemplateColumn();
content t2=new content();
t2.field=thecel()[i];
tm.ItemTemplate=t2;
tm.HeaderText=thecel()[i];
if (thecel()[i]!="id")
TheGrid.Columns.Add(tm);
/*/
//*
BoundColumn tm=new BoundColumn();
tm.HeaderText=thecel()[i];
tm.DataField=thecel()[i];
if (thecel()[i]!="id")
TheGrid.Columns.Add(tm);
//*/
为什么换成模版后,编辑状态下就没用,不能编辑,奇怪
!-_-默认就是不能编辑的,需要编辑要单独设定
tm.EditItemTemplate =txtbox;
2005-6-1
终于找出出错的原因了,SQL这个属性没初始化
不知怎么弄了,只好把它用SESSION存取了!-_-
在GooGle中搜索关于“DataGrid控件”的文章
name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/cpa/ads?client=ca-pub-2574632228537424&cpa_choice=CAAQnaWdzgEaCINObkyS6oFDKIvN93M&oe=gb2312&dt=1164818953343&lmt=1163047541&format=468x60_as_rimg&output=html&url=http%3A%2F%2Fwww.hubro.net%2Fitem%2F82%2F®ion=_google_cpa_region_&ref=http%3A%2F%2Fwww.google.com%2Fsearch%3Fhl%3Dzh-CN%26newwindow%3D1%26q%3D.net%2B%2B%2Bcheckbox%25E7%259A%2584datagrid%25E6%258E%25A7%25E4%25BB%25B6%26lr%3D&cc=100&u_h=800&u_w=1280&u_ah=772&u_aw=1280&u_cd=32&u_tz=480" frameborder="0" width="468" scrolling="no" height="60" allowtransparency="allowtransparency">
by
直接继承DataGrid了,再重载了他的一些属性,实现了自编辑