遍历datalist中的checkbox,并获取此时的值
原文发布时间为:2009-04-29 —— 来源于本人的百度文章 [由搬家工具导入]
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SqlConnection conn = new SqlConnection("server=.;uid=sa;pwd=sa;database=Northwind");
SqlDataAdapter a = new SqlDataAdapter("select top 5 productname from products", conn);
DataSet ds = new DataSet();
a.Fill(ds);
DataList1.DataSource = ds;
DataList1.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string num = "";
foreach (Control c in DataList1.Controls)
{
CheckBox chk = (CheckBox)c.FindControl("CheckBox1");
if (chk.Checked)
num += chk.Text+"<br>";
}
Response.Write(num);
}
两点注意:
1.要用服务器端控件checkbox
2.绑定的时候要写在if(!ispostback)条件下
遍历datalist中的checkbox,并获取此时的值的更多相关文章
- EF中执行存储过程,获取output返回值
EF不能直接支持执行存储过程,于是使用转化成执行SQL语句的形式,却怎么也获取不到output的值,折腾的好久,终于解决了,分享下曲折的经历: public int AddVote(int title ...
- JQuery 遍历table中的checkbox 并对行数据进行校验
JQuery中confirm的使用 $(document).ready(function () { $("#Btn_Print").click(function () { var ...
- ashx页面中context.Session["xxx"]获取不到值的解决办法
在 aspx和aspx.cs中,都是以Session["xxx"]="aaa"和aaa=Session["xxx"].ToString()进 ...
- 在freemarker文件中,html标签获取后台的值
1.<#assign a='3333' /> 2.<input type="text" id="name" name="name&q ...
- dataList中实现用复选框一次删除多行问题
先遍历每一行,判断checkBox是否选中,再获取选中行的主键Id 删除就行了 ,,,foreach(DatalistRow rowview in Datalist.Rows) //遍历Datalis ...
- js技术之根据name获取input的值
一.前端的代码 <p>Name: <input type='text', name = 'name'/></p> <p>Age: <input t ...
- asp.net单击头模板中的checkbox,实现datalist中所有chebox的全选和取消
转载时请以超链接形式标明文章原始出处和作者信息及本声明http://blueseach.blogbus.com/logs/31281126.html 使用C#和javascript都可以实现,第二种更 ...
- jQuery遍历table中的tr td并获取td中的值
jQuery遍历table中的tr td并获取td中的值 $(function(){ $("#tableId tr").find("td").each(func ...
- Web版需求征集系统所得1,servlet中获取checkbox复选框的值
servlet中获取checkbox复选框的值 </tr> <tr> <td align="right">研究类型</td> < ...
随机推荐
- node 中的redis使用
1.创建sql.config.js 配置文件 : var redis_db = { ", "URL":"127.0.0.1", "OPTIO ...
- yii2 RUL的生成
通常情况下,会使用 yii\helpers\Url 使用Url类来生成想要的URL地址(链接) Url提供的方法大都是静态方法,不需要对类进行实例化 1.1 最常用的 Url::to() 1.2. b ...
- python读取xls文件
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/10/17 14:41 # @Author : Sa.Song # @Desc ...
- 机顶盒demux的工作原理
在机顶盒中demux部分相对来说是比较复杂的部分,对于机顶盒软件开发的新手来说通常在这里会遇到一些困难,今天特意研究了一下驱动层代码,有一点自己的理解,因此写下来记录一下学习过程. 机顶盒中数据是如何 ...
- ACM-ICPC 2018 徐州赛区网络预赛
A. Hard to prepare #include <bits/stdc++.h> using namespace std; ; ]; ]; int main() { int T; i ...
- Codeforces Round #459 (Div. 2):B. Radio Station
B. Radio Station time limit per test2 seconds memory limit per test256 megabytes Problem Dsecription ...
- POJ3436------ACM Computer Factory
题目链接 ACM Computer Factory Description As you know, all the computers used for ACM contests must be i ...
- 《Scrum实战》第4次课【全职的Scrum Master】作业汇总
1组: 孟帅 http://www.cnblogs.com/mengshuai1982/p/7375008.html 3组: 张亚辉 http://www.jianshu.com/p/df9eee08 ...
- phpmyadmin4.8.1后台getshell
phpmyadmin4.8.1后台getshell 包含文件进行getshell 姿势: ① 建立数据库的,新建表,字段名为一句话木马. 会生成对应的数据库文件,相应文件的路径查看 select @@ ...
- Python subprocess.Popen中communicate()和wait()区别
刚开始我是使用的wait(),但是当adb命令返回太多时,程序就会卡死,查询得知原因后,才使用了communicate(),communicate()返回一个元组:(stdoutdata, stder ...