C# Repeater嵌套循环[通俗易懂]

C# Repeater嵌套循环[通俗易懂]前台代码:<asp:RepeaterID=”rptList”runat=”server”OnItemDataBound=”users_list”><HeaderTemplate><tablewidth=”100%”border=”0″cellspacing=”0″cellpadding=”0″…

大家好,又见面了,我是你们的朋友全栈君。

前台代码:

<asp:Repeater ID="rptList" runat="server" OnItemDataBound="users_list">
<HeaderTemplate>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="ltable">
<thead>
<tr>
<th style="width: 80px;">
主表字段
</th>
<th style="width: 320px;">
<table width="100%" border="0" cellpadding="5" cellspacing="1">
<tr bgcolor="#FFFFFF">
<th width="50%">
<div align="center">
<font>对应字段1</font></div>
</th>
<th width="50%">
<div align="center">
<font>对应字段1</font></div>
</th>
</tr>
</table>
</th>
<th style="width: 100px;">
<i class="iconfont icon-setting bigger"></i>操作
</th>
</tr>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
主表数据
</td>
<td>
<table width="100%" border="0">
<asp:Repeater ID="users_list" runat="server">
<ItemTemplate>
<tr bgcolor="#FFFFFF">
<td width="50%" align="center">
对应数据1
</td>
<td width="50%" align="center">
对应数据2
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
</td>
<td>
<a href="#">修改</a>
<a href="#">查看</a>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<%#rptList.Items.Count == 0 ? "<tr><td align=\"center\" colspan=\"3\"><font color=\"#F89406\">暂无记录</font></td></tr>" : ""%>
</table>
</FooterTemplate>
</asp:Repeater>

后台代码:

      	//主表数据绑定
private void RptBind(string _strWhere, string _orderby)
{ 

BLL.xs_user bll = new BLL.xs_user();
this.rptList.DataSource = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount, "manager_qualification_certificate");
this.rptList.DataBind();
}
//副表数据绑定
protected void users_list(object sender, RepeaterItemEventArgs e)
{ 

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{ 

string ID = ((DataRowView)e.Item.DataItem).Row["ID"].ToString();//获得对应ID
Repeater repeater= (Repeater)e.Item.FindControl("users_list");//找到要绑定数据的Repeater
//Literal Lit = ((Literal)e.Item.FindControl("Lit_cn"));
//Literal Lit_remark = ((Literal)e.Item.FindControl("Lit_remark"));
if (repeater!= null)
{ 

DataTable dt = 获取到的数据;
//string remark = "";
//foreach (DataRow item in dt.Rows)
//{ 

// if (!string.IsNullOrWhiteSpace(item["u_remark"].ToString()))
// { 

// remark += item["name"].ToString() + ":" + item["u_remark"].ToString() + "。";
// }
//}
//Lit_remark.Text = remark + Lit_remark.Text;
repeater.DataSource = dt;
repeater.DataBind();
}
}
}

共同学习,一起进步,有些东西我也不懂,可以大家一起讨论!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/159112.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • JAVA中Object转String

    JAVA中Object转String1.object.toString()方法这种方法要注意的是object不能为null,否则会报NullPointException,一般别用这种方法。2.String.valueOf(object)方法这种方法不必担心object为null的问题,若为null,会将其转换为”null”字符串,而不是null。这一点要特别注意。”null”和null不是一个概念。3….

  • 如何避免重复提交?分布式服务的幂等性设计!

    来源:https://www.cnblogs.com/QG-whz/p/10372458.html作者:melonstreet 为什么需要保证幂等性 编程中的“幂等性”是指任意多次…

  • objective c源码_以下C代码有哪些错误

    objective c源码_以下C代码有哪些错误我是前言看开源代码时,总会看到一些大神级别的代码,给人眼前一亮的感觉,多数都是被淡忘的C语言语法,总结下objc写码中遇到的各类非主流代码技巧和一些妙用:[娱乐向]objc最短的方法声明[C]结构体的初始化[C]三元条件表达式的两元使用[C]数组的下标初始化[objc]可变参数类型的block[objc]readonly属性支持扩展的写法[C]小括号内联复合表达式[娱乐向]奇葩的C

    2022年10月18日
  • VS2015序列号_autocad2008激活序列号

    VS2015序列号_autocad2008激活序列号
    VisualStudioTeamSystem2008TeamSuite(vs2008)正式中文版   
    VS2008简体中文正式版序列号大全
      
    1.VisualStudio2008ProfessionalEdition:
    XMQ2Y-4T3V6-XJ48Y-D3K2V-6C4WT
      
    2.VisualStudio2008TeamTestLoadAgent:
    WPX3J-BXC3W-BPYW

  • WindowManager.LayoutParams.FLAG_SECURE_congestion window

    WindowManager.LayoutParams.FLAG_SECURE_congestion windowpublicstaticclassWindowManager.LayoutParamsextends ViewGroup.LayoutParamsimplements Parcelablejava.lang.Object   ?android.view.ViewGroup.LayoutParams    ?

  • suse linux rpm 安装

    suse linux rpm 安装安装rpm包时遇到error:Faileddependencies:错误在linux下安装rpm包时经常会遇到下面这个问题:error:Faileddependencies:……………………………………………..省略号表示安装此rpm缺少的包。遇到此问题时可以在安装rpm包命令的后面加两个参数,如:

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号