asp:Repeater控件的应用,System.Data.DataRowView

前台代码

  1. <body>
  2.     <form id="form1" runat="server">
  3. <!-- start parent repeater -->
  4.          
  5. 例子一:
  6. <%--
  7. <asp:repeater id="parentRepeater" runat="server">
  8.    <itemtemplate>
  9.       <b><%# DataBinder.Eval(Container.DataItem, "TerritoryID")%></b><br>
  10.       <!-- start child repeater -->
  11.       <asp:repeater id="childRepeater" datasource='<%# ((System.Data.DataRowView)Container.DataItem).Row.GetChildRows("CustomerName") %>' runat="server">
  12.          <itemtemplate>
  13.             <%# DataBinder.Eval(Container.DataItem, "[/"CustomerName/"]")%><br>
  14.          </itemtemplate>
  15.       </asp:repeater>
  16.       <!-- end child repeater -->
  17.    </itemtemplate>
  18. </asp:repeater>--%>
  19.                          
  20. 例子二:
  21. <asp:repeater id="parentRepeater" runat="server">
  22.    <itemtemplate>
  23.       <b><%# DataBinder.Eval(Container.DataItem, "TerritoryID")%></b><br>
  24.       <!-- start child repeater -->
  25.       <!-- end child repeater -->
  26.    </itemtemplate>
  27.    <ItemTemplate>
  28.    <table><tr><td> <img src="" /></td>
  29.    <td><%# DataBinder.Eval(Container.DataItem, "Name")%></td>
  30.    <td><%# DataBinder.Eval(Container.DataItem, "CountryRegionCode")%></td>
  31.    </tr>
  32.    </table>
  33.    </ItemTemplate>
  34. </asp:repeater>
  35. <!-- end parent repeater -->
  36.     </form>
  37. </body>

后台代码

  1.  using System;
  2. using System.Data;
  3. using System.Data.SqlClient;
  4. using System.Web;
  5. using System.Web.SessionState;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. public partial class WebForm1 : System.Web.UI.Page
  9.     {
  10.          protected System.Web.UI.WebControls.Repeater parentRepeater;
  11.       public void Page_Load(object sender, EventArgs e)
  12.       {
  13.         //Create the connection and DataAdapter for the Authors table.
  14.          SqlConnection cnn = new SqlConnection("server=(local);database=sampledatabase; Integrated Security=SSPI ;");
  15.          SqlDataAdapter cmd1 = new SqlDataAdapter("select * from TDemo_SalesTerritory",cnn);
  16.          //Create and fill the DataSet.
  17.          DataSet ds = new DataSet();
  18.          cmd1.Fill(ds, "SalesTerritory");
  19.          //Create a second DataAdapter for the Titles table.
  20.          SqlDataAdapter cmd2 = new SqlDataAdapter("select * from TDemo_CustomerInfo",cnn);
  21.          cmd2.Fill(ds, "CustomerInfo");
  22.          //Create the relation bewtween the Authors and Titles tables.
  23.          ds.Relations.Add("CustomerName", ds.Tables["SalesTerritory"].Columns["TerritoryID"], ds.Tables["CustomerInfo"].Columns["TerritoryID"]);
  24.          //Bind the Authors table to the parent Repeater control, and call DataBind.
  25.          parentRepeater.DataSource = ds.Tables["SalesTerritory"];
  26.          Page.DataBind();
  27.          //Close the connection.
  28.          cnn.Close();
  29.    }
  30. }

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
java.lang.ExceptionInInitializerError at com.example.demo.MyBatisExampleDemoTest.test1(MyBatisExampleDemoTest.java:23) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.ParentRunner.run(ParentRunner.java:413) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38) at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55) Caused by: org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession. ### The error may exist in SQL Mapper Configuration ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.datasource.DataSourceException: Unknown DataSource property: serverTimezone at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:52) at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:36) at com.bosssoft.hr.train.j2se.mybatis.utils.MyBatisUtils.<clinit>(MyBatisUtils.java:27) ... 28 more Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.datasource.DataSourceException: Unknown DataSource property: serverTimezone at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:122) at org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:99) at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:50) ... 30 more Caused by: org.apache.ibatis.datasource.DataSourceException: Unknown DataSource property: serverTimezone at org.apache.ibatis.datasource.unpooled.UnpooledDataSourceFactory.setProperties(UnpooledDataSourceFactory.java:55) at org.apache.ibatis.builder.xml.XMLConfigBuilder.dataSourceElement(XMLConfigBuilder.java:329) at org.apache.ibatis.builder.xml.XMLConfigBuilder.environmentsElement(XMLConfigBuilder.java:283) at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:117) ... 32 more
最新发布
07-15

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值