前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Repeater,DataList,DataGrid

Repeater,DataList,DataGrid

作者头像
用户1075292
发布2018-01-23 15:55:31
7530
发布2018-01-23 15:55:31
举报
文章被收录于专栏:听雨堂听雨堂

   输出表:

代码语言:js
复制
   string a="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\data.mdb;Persist Security Info=False;"; 
   OleDbConnection cn=new OleDbConnection(a); 
   OleDbCommand cm=new OleDbCommand("select * from test2",cn); 
   cn.Open(); 
   OleDbDataReader  ad =  cm.ExecuteReader(); 
 
   while(ad.Read()) 
   { 
    Response.Write (ad.GetValue(0).ToString()+","+ad.GetValue(1) + "<br>"); 
   }

Reapter使用 绑定:

代码语言:js
复制
    Repeater1.DataSource=ds; 
   Repeater1.DataMember=("table1"); 
   Repeater1.DataBind(); 

模板写法:

代码语言:js
复制
     <HeaderTemplate> 
      <table> 
      <tr> 
        <td>标题一</td> 
        <td>标题二</td> 
      </tr> 
     </HeaderTemplate> 
     <ItemTemplate> 
      <tr> 
       <td><%#  DataBinder.Eval(Container.DataItem,"aa")%></td> 
          <td><%#  DataBinder.Eval(Container.DataItem,"bb")%></td> 
      </tr> 
     </ItemTemplate> 
     <AlternatingItemTemplate> 
      <tr> 
       <td bgcolor=#ffffcc><%#  DataBinder.Eval(Container.DataItem,"aa")%></td> 
          <td bgcolor=#ffffcc><%#  DataBinder.Eval(Container.DataItem,"bb")%></td> 
      </tr> 
     </AlternatingItemTemplate> 
     <FooterTemplate> 
      </table> 
     </FooterTemplate> 

DataList写法跟repeater类似,不过默认是列表,所以不要写头和尾 DataGrid可以分页

与页面的交互:按钮较好,使用时考虑到网页的一般情况即可

IsPostBack 真第二次加载,假:首次加载

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2005-05-01 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档