asp.net repeater_asp.net core

asp.net repeater_asp.net coreasp.net在Repeater嵌套的Repeater中使用复选框来自森大科技官方博客http://www.cnsendblog.com/index.php/?p=109.aspx文件中:<%–顶层Repeater–%><asp:RepeaterID=“rptChannel”runat=“server”><%#Eval(“ChannelName”…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

asp.net在Repeater嵌套的Repeater中使用复选框
来自森大科技官方博客 http://www.cnsendblog.com/index.php/?p=109
.aspx文件中:
<%–顶层Repeater–%>
<asp:Repeater ID=“rptChannel” runat=“server”>

<%# Eval(“ChannelName”)%>
<%–嵌套的Repeater,指定使用后台创建的Releation来获取数据源–%>
<asp:Repeater ID=“rptClassify” DataSource=’<%# Eval(“myrelation”) %>’ runat=“server”>

<asp:Label ID=“lbl_FlagName” runat=“server” Text=’<%# Eval(“FlagName”)%>’></asp:Label>

</asp:Repeater >
<%–end 嵌套的Repeater,指定使用后台创建的Releation来获取数据源–%>

</asp:Repeater >
<%–end 顶层Repeater–%>
.aspx.cs文件中:
#region Repeater嵌套的Repeater中使用复选框
//★Repeater嵌套-经典运用★
string sqlstr1, sqlstr2;
sqlstr1 = “select distinct a.ChannelID,b.ChannelName from IE_FlagGroup a left join IE_Channel b on a.ChannelID=b.ChannelID where a.isClose=0 order by a.ChannelID asc”;
sqlstr2 = “select * from IE_FlagGroup where isClose=0 order by FlagID asc”;
DataSet dsChannel = DBFun.dataSetTwo(sqlstr1, “Channel”, sqlstr2, “Classify”, “myrelation”);
dsChannel.Relations.Add(“myrelation”, dsChannel.Tables[“Channel”].Columns[“ChannelID”], dsChannel.Tables[“Classify”].Columns[“ChannelID”], false);
this.rptChannel.DataSource = dsChannel.Tables[“Channel”];//绑定顶层Repeater(注意:只要绑定顶层就好,嵌套层不能绑定)
this.rptChannel.DataBind();
#endregion
//……略相关数据库操作代码
#region 设置Repeater嵌套的Repeater中相应的复选框为选中状态
string[] selTeamflag = drw[“Teamflag”].ToString().Split(’,’);
HtmlInputCheckBox checkBox;
Repeater rpClass;
for (int i = 0; i < this.rptChannel.Items.Count; i++)
{

rpClass = (Repeater)this.rptChannel.Items[i].FindControl(“rptClassify”);
for (int j = 0; j < rpClass.Items.Count; j++)
{

checkBox = (HtmlInputCheckBox)rpClass.Items[j].FindControl(“chk_FlagID”);
if (selTeamflag.Contains(checkBox.Value))
checkBox.Checked = true;
}
}
#endregion
#region 获取Repeater嵌套的Repeater中的复选框所选择的值的组合,以”,”隔开
string str_Teamflag = “”;
HtmlInputCheckBox checkBox;
Repeater rpClass;
for (int i = 0; i < this.rptChannel.Items.Count; i++)
{

rpClass = (Repeater)this.rptChannel.Items[i].FindControl(“rptClassify”);
for (int j = 0; j < rpClass.Items.Count; j++)
{

checkBox = (HtmlInputCheckBox)rpClass.Items[j].FindControl(“chk_FlagID”);
if (checkBox.Checked)
str_Teamflag += checkBox.Value + “,”;
}
}
if (str_Teamflag != “”)
{

//去除最后一个字符
//str_Teamflag = str_Teamflag.Substring(0, str_Teamflag.Length – 1);
str_Teamflag = str_Teamflag.Remove(str_Teamflag.Length – 1);
}
#endregion

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

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/182501.html原文链接:https://javaforall.net

赞 (0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • spring自定义注解实现(spring里面的注解)

    java注解:附在代码中的一些元信息,用于在编译、运行时起到说明、配置的功能。一、元注解java提供了4中元注解用于注解其他注解,所有的注解都是基于这四种注解来定义的。@Target注解:用于描述注解的使用范围,超出范围时编译失败。 取值类型(ElementType):  1.CONSTRUCTOR:用于描述构造器  2.FIELD:用于描述域(成

    2022年4月15日
  • centos卸载宝塔面板_centos如何关闭防火墙

    centos卸载宝塔面板_centos如何关闭防火墙centos宝塔卸载后防火墙还在的问题解决#宝塔防火墙进程名称#宝塔防火墙怎关闭#宝塔防火墙进程名称

    2022年9月6日
  • 怎么从一台电脑的浏览器输入地址访问另一台电脑服务器(WAMP服务器已搭建,PHPSTORM装好了)…

    怎么从一台电脑的浏览器输入地址访问另一台电脑服务器(WAMP服务器已搭建,PHPSTORM装好了)…

    2021年9月25日
  • SQLserver基础语句大全[通俗易懂]

    SQLserver基础语句大全[通俗易懂]SQL基础结构化查询语言(StructuredQueryLanguage)简称SQL,是一种特殊目的的编程语言,是一种数据库查询和程序设计语言,用于存取数据以及查询、更新和管理关系数据库系统;同时也是数据库脚本文件的扩展名。SQLDML和DDL可以把SQL分为两个部分:数据操作语言(DML)和数据定义语言(DDL)。SQL(结构化查询语言)是用于执行…

    2022年5月5日
  • pip安装scrapy失败_scrapy框架运行

    pip安装scrapy失败_scrapy框架运行错误如图所示,running setup.py install for Twisted…..errorTwisted依赖库安装报错,重新下载手动安装一下下载网址:https://www.lfd.uci.edu/~gohlke/pythonlibs注意:看下安装的python是什么版本,我安装的python 3.9.0,就下载cp39,64位的下载安装的版本不对,就会报:Twisted-20.3.0-cp38-cp38-win_amd64.whl is not a support…

    2022年8月18日
  • C++ this指针详解

    C++ this指针详解this指针只能在一个类的成员函数中调用,它表示当前对象的地址。下面是一个例子:​voidDate::setMonth(intmn){month=mn;//这三句是等价的this->month=mn;(*this).month=mn;}​1.this只能在成员函数中使用。…

    2022年5月13日

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

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