DataList CheckBox多选删除时处理方法
来源:互联网 发布:iphone数据流量打不开 编辑:程序博客网 时间:2024/06/02 18:24
前台
<asp:datalist id="score" runat="server" Width="780" Height="80px">
<headertemplate>
</headertemplate>
<itemtemplate>
<table width="780" border="0" cellpadding="0" cellspacing="0">
<tr id="chk" height="30" Runat="server">
<td width="30">
<div align="Center">
<input type="hidden" id="SelectedID" runat="server" value='<%# DataBinder.Eval(Container.DataItem, "id")%>' NAME="SelectedID"/>
<asp:CheckBox ID="chkExport" onclick="javascript:clickcompareBox(this);" Runat="server" />
</div>
</td>
<td width="390" rowspan="1" class="zhong13h"><a href='trydetail.aspx?id=<%# DataBinder.Eval(Container.DataItem,"id").ToString() %>' target=_blank>
<%# CutString(DataBinder.Eval(Container.DataItem,"title").ToString(),27) %>
</a>
</td>
<td width="260" class="zhong13h">
<%# CutString(DataBinder.Eval(Container.DataItem,"keys").ToString(),17) %>
</td>
<td width="100" rowspan="1" class="zhong13h"><div align="center"><%# DataBinder.Eval(Container.DataItem,"lutime","{0:D}").ToString() %></div>
</td>
</tr>
</table>
</itemtemplate>
<alternatingitemtemplate>
<table width="780" border="0" cellpadding="0" cellspacing="0">
<tr id="chk" height="30" bgcolor="#f6f6f6" Runat="server">
<td width="30">
<div align="Center">
<input type="hidden" id="SelectedID" runat="server" value='<%# DataBinder.Eval(Container.DataItem, "id")%>' NAME="SelectedID"/>
<asp:CheckBox ID="chkExport" onclick="javascript:clickcompareBox(this);" Runat="server" />
</div>
</td>
<td width="390" rowspan="1" class="zhong13h"><a href='trydetail.aspx?id=<%# DataBinder.Eval(Container.DataItem,"id").ToString() %>' target=_blank>
<%# CutString(DataBinder.Eval(Container.DataItem,"title").ToString(),27) %>
</a>
</td>
<td width="260" class="zhong13h">
<%# CutString(DataBinder.Eval(Container.DataItem,"keys").ToString(),17) %>
</td>
<td width="100" rowspan="1" class="zhong13h"><div align="center"><%# DataBinder.Eval(Container.DataItem,"lutime","{0:D}").ToString() %></div>
</td>
</tr>
</table>
</alternatingitemtemplate>
</asp:datalist>
<SCRIPT language="javascript">
bgColor = "FEEEE0";
function clickcompareBox(box) {
if(box.checked){
if(box.id.length==21)
{
var trTag =document.getElementById(box.id.substring(0,15));
// var trTag=score__ctl1_chk;
trTag.bgColor=bgColor;
// score__ctl1_chk.bgColor=bgColor;
// alert(trTag);
//alert(trTag.length);
}
else
if(box.id.length==22)
{
var trTag =document.getElementById(box.id.substring(0,16));
trTag.bgColor=bgColor;
}
else
if(box.id.length==23)
{
var trTag =document.getElementById(box.id.substring(0,17));
trTag.bgColor=bgColor;
}
}
else
{
if(box.id.length==21)
{
var trTag =document.getElementById(box.id.substring(0,15));
var countId = box.id.substring(10,11);
}
else
if(box.id.length==22)
{
var trTag =document.getElementById(box.id.substring(0,16));
var countId = box.id.substring(10,12);
}
else
if(box.id.length==23)
{
var trTag =document.getElementById(box.id.substring(0,17));
var countId = box.id.substring(10,13);
}
if(countId%2 != 0){
trTag.bgColor="ffffff";
}else{
trTag.bgColor="F6F6F6";
}
}
}
</SCRIPT>
后台:-----------------------
//
System.Web.UI.WebControls.CheckBox chkExport;
System.Collections.ArrayList oExArgs = new System.Collections.ArrayList();
string sID;
string id;
foreach(DataListItem oDataListItem in score.Items)
{
chkExport = (CheckBox)oDataListItem.FindControl("chkExport");
if( chkExport.Checked)
{
sID = ((HtmlInputHidden)oDataListItem.FindControl("SelectedID")).Value;
oExArgs.Add(sID);
}
}
int i = 0;
string s="select id,title,keys,content,cw_pic,d_class,x_class,lutime from cw_jy where 1=1 ";
string s1="";
for( i = 0;i<oExArgs.Count;i++)
{
if (oExArgs[i]!=null)
{
id=oExArgs[i].ToString().Trim();
if (i==0)
{
s1=s1+" and id="+id;//这里是我自己写的,请在这里构造你的删除语句ok(就是改成你自己的动作即可)
}
else
{
s1=s1+" or id="+id;
}
}
else
{
Response.Write("<script laguage='javascript'>history.back();</script>");
}
}
if(s!=(s+s1))
{
Session["str"]=s+s1;
Response.Write("<script laguage='javascript'>window.open('detail.aspx');</script>");
}
else
{
Response.Write("<script laguage='javascript'>alert('请选择!');</script>");
}
- DataList CheckBox多选删除时处理方法
- DataList CheckBox 全选删除
- checkbox多选删除
- asp.net之DataList里的CheckBox实现全选、反选删除
- php一次性删除前台checkbox多选内容的方法
- ASP,checkbox多选删除
- android checkbox多选删除
- DataList中CheckBox实现单选
- datalist删除多行记录
- Datalist 删除
- 多选删除,listview滑动时checkbox错位措施
- 关于checkbox的ListView实现多选、全选、反选、删除更简单的方法
- .net中checkbox的多选删除
- 对checkbox进行多选删除
- listview中checkbox多选单选删除
- php 用checkbox一次性删除多条记录的方法
- datalist gridview编辑.删除多行
- DataList的修改删除
- 命名空间2
- GDB调试精粹及使用实例 转载
- Tomcat自身的调整策略
- Borland成为过去时,说明经营一家公司的难度远远大于【操作系统+编译器+数据库】的难度!
- 且思且行
- DataList CheckBox多选删除时处理方法
- 好友列表的实现
- First Use of Android! Hello android.
- some songs
- 免费电子书下载 网站
- 《Dojo构建Ajax应用程序》勘误与问题专用贴
- 天津人骗子181561862,20507800
- From China daily
- 关于app.config