ASP.WEB Form 几点知识
1、GridView 行的多选
<asp:TemplateField ControlStyle-Width="30" HeaderText="选择" >
<ItemTemplate>
<asp:CheckBox ID="DeleteThis" onclick="javascript:CCA(this);" runat="server" />
</ItemTemplate>
</asp:TemplateField> private string GetSelIDlist()
{
string idlist = "";
bool BxsChkd = false;
for (int i = 0; i < gridView.Rows.Count; i++)
{
CheckBox ChkBxItem = (CheckBox)gridView.Rows[i].FindControl("DeleteThis");
if (ChkBxItem != null && ChkBxItem.Checked)
{
BxsChkd = true;
//#warning 代码生成警告:请检查确认Cells的列索引是否正确
if (gridView.DataKeys[i].Value != null)
{
idlist += gridView.DataKeys[i].Value.ToString() + ",";
}
}
}
if (BxsChkd)
{
idlist = idlist.Substring(0, idlist.LastIndexOf(","));
}
return idlist;
}
/// <summary>
/// 批量删除数据
/// </summary>
public bool DeleteList(string Idlist )
{
StringBuilder strSql=new StringBuilder();
strSql.Append("delete from General_KnowledgePoint ");
strSql.Append(" where Id in ("+Idlist + ") ");
int rows=DbHelperSQL.ExecuteSql(strSql.ToString());
if (rows > 0)
{
return true;
}
else
{
return false;
}
}
方式二:
<script type="text/JavaScript">
function CheckBoxAll() {
if ($("input[id*='ContentPlaceHolder1_GVListShow_chkAllProp']").attr("checked") == true) {
$("input[id*='chkSelect']").attr("checked", true);
}
else {
$("input[id*='chkSelect']").attr("checked", false);
}
}
</script>
<asp:TemplateField HeaderText="选择">
<HeaderTemplate>
<input type="checkbox" id="chkAllProp" runat="server" onclick="CheckBoxAll()" />全选
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" Text="选择" />
</ItemTemplate>
</asp:TemplateField>
//取主键值
string GetIndexKey()
{
string indexKey = "";
for (int i = 0; i <= GVListShow.Rows.Count - 1; i++)
{
CheckBox cbox = (CheckBox)GVListShow.Rows[i].FindControl("chkSelect");
if (cbox.Checked == true)
{
if (indexKey == "")
{
indexKey = GVListShow.Rows[i].Cells[0].Text.Trim();
}
else
{
indexKey += "," + GVListShow.Rows[i].Cells[0].Text.Trim();
}
}
}
return indexKey;
}
相关实例:
//批量删除
protected void btnDelect_Click(object sender, EventArgs e)
{
string indexKeys = GetIndexKey();
if (indexKeys != "")
{
string strWhere = string.Format("Id in ({0})", indexKeys);
DotNet.BLL.Web_Article BLL = new DotNet.BLL.Web_Article();
if (1 <= BLL.DeleteWhere(strWhere, null))
{
Web_ArticleBind();
}
}
} protected void btnTop_Click(object sender, EventArgs e)
{
string indexKeys = GetIndexKey();
if (indexKeys != "")
{
DotNet.BLL.Web_Article BLL = new DotNet.BLL.Web_Article();
int maxTopNum = 0;
string strGetWhere = "ComanyId = " + USER.SchoolId;
object selMaxTopNum = BLL.GetSingle("Max(OrderNum)", strGetWhere, null);
string strWhere = string.Format("Id in ({0})", indexKeys);
if (selMaxTopNum != null)
{
maxTopNum = int.Parse(selMaxTopNum.ToString()) + 1;
if (1 <= BLL.Update("OrderNum = " + maxTopNum, strWhere, null))
{
Web_ArticleBind();
}
}
}
} protected void btnCancelTop_Click(object sender, EventArgs e)
{
string indexKeys = GetIndexKey();
if (indexKeys != "")
{
DotNet.BLL.Web_Article BLL = new DotNet.BLL.Web_Article();
int maxTopNum = 0;
//object selMaxTopNum = BLL.GetSingle("Max(top_num)", "", null);
string strWhere = string.Format("Id in ({0})", indexKeys);
if (1 <= BLL.Update("OrderNum = " + maxTopNum, strWhere, null))
{
Web_ArticleBind();
}
}
} //审核新闻
protected void btnPass_Click(object sender, EventArgs e)
{
string indexKeys = GetIndexKey();
if (indexKeys != "")
{
DotNet.BLL.Web_Article BLL = new DotNet.BLL.Web_Article();
string strWhere = string.Format("Id in ({0})", indexKeys);
if (1 <= BLL.Update("StateNum = 2,StateName='已审核' ", strWhere, null))
{
//Response.Redirect(Request.Url.ToString());
Web_ArticleBind(); }
}
} //取消审核
protected void btnUnpass_Click(object sender, EventArgs e)
{
string indexKeys = GetIndexKey();
string strUpdate = "SavedOn=getdate()";
if (indexKeys != "")
{
DotNet.BLL.Web_Article BLL = new DotNet.BLL.Web_Article();
string strWhere = string.Format("Id in ({0})", indexKeys);
if (1 <= BLL.Update(strUpdate+",StateNum = 1,StateName='未审核'", strWhere, null))
{
//Web_NewsBind();
//Response.Redirect(Request.Url.ToString());
Web_ArticleBind();
}
}
} //转移新闻栏目
protected void btnChangeCategory_Click(object sender, EventArgs e)
{
if (DdlCategoryIdNew.SelectedValue.Trim() == "0")
{
DotNet.Common.MessageBox.Show(this, "请选择栏目");
return;
} string indexKeys = GetIndexKey();
if (indexKeys != "")
{
DotNet.BLL.Web_Article BLL = new DotNet.BLL.Web_Article();
string strField = "CategoryId = @CategoryId,CategoryName = @CategoryName";
Hashtable ht = new Hashtable();
ht.Add("@CategoryId", DdlCategoryIdNew.SelectedValue.Trim());
ht.Add("@CategoryName", DdlCategoryIdNew.SelectedItem.Text.Trim());
string strWhere = string.Format("Id in ({0})", indexKeys);
if (1 <= BLL.Update(strField, strWhere, ht))
{
Web_ArticleBind();
}
}
}
ASP.WEB Form 几点知识的更多相关文章
- ASP.Net Web Form<一> aspx文件编译及呈现
对比复习下JSP 1.jsp的本质是Servlet ,会在第一次被访问时会被翻译成一个类文件,从此对这个页面的访问都是由这个类文件执行后进行输出. aspx 本质是IHttpHandler 2.jsp ...
- ASP.NET MVC与ASP.NET Web Form简单区别与适用场景
概论: Asp.net 微软 提供web开发框架或者技术.分Web Form和ASP.NET MVC.下面简单说明各自优缺点及使用场景. Web Form 优点: 1.支持丰富的服务器控件.如:Gr ...
- Web Form 和asp.net mvc 差别
Asp.net MVC 和web Form的基本区别 Web Form ASP.NET MVC 视图和逻辑紧密耦合 视图和逻辑分离 页面(给予文件的URL) 控制器(基于路由的URL) 状态管理(视图 ...
- Asp.net web form url route使用总结
asp.net web form 使用URL路由 注不是mvc中的路由 一.前台控件使用路由,通过表达式生成url地址,注意给路由参数赋值,防止使用了其他路由表达式值方式1:<asp:Hyper ...
- ASP.NET Web Form和MVC中防止F5刷新引起的重复提交问题
转载 http://www.cnblogs.com/hiteddy/archive/2012/03/29/Prevent_Resubmit_When_Refresh_Reload_In_ASP_NET ...
- 转载ASP.NET MVC 和ASP.NET Web Form简单区别
转载原地址 http://www.cnblogs.com/lei2007/p/3315431.html 概论: Asp.net 微软 提供web开发框架或者技术.分Web Form和ASP.NET ...
- 关于asp.net web form 和 asp.net mvc 的区别
asp.net web forms 有什么缺陷? 1.视图状态臃肿:服务器和客户端传输过程中包含了大量的试图状态——在现在的web程序中甚至多达几百kb,而且每次往返都会请求,导致服务器请求带宽增加, ...
- 在asp.net web form项目中添加webapi接口
我有一个支付宝服务网关是ASP.NET WEB FORM项目,但是最近这个网关需要对外提供几个接口,想了下,使用web api比较合适,实现很简单,GO 1,首先添加一个文件夹名字叫App_Start ...
- ASP.NET MVC与ASP.NET Web Form简单区别
概论: Asp.net 微软 提供web开发框架或者技术.分Web Form和ASP.NET MVC.下面简单说明各自优缺点及使用场景. Web Form 优点: 1.支持丰富的服务器控件.如:Gr ...
随机推荐
- Sql效能优化总结(续)- sql语句优化篇
今晚继续进行Sql效能问题的分享,今天主要是一些具体的sql优化方法和思路分享,若看过后你也有其他想法,欢迎一起探讨,好了,进入今天的主题. 针对性地对一些耗资源严重的具体应用进行优化 出现效能问题时 ...
- 使用badboy录制脚本 结合Jmeter一起测试。
1.badboy介绍 Badboy是一款不错的Web自动化测试工具,如果你将它用于非商业用途,或者用于商业用途安装Badboy 的机器数量不超过5台,你是不需要为它支付任何费用的.Badboy提供了将 ...
- php != 和 !== 的区别
== and != do not take into account the data type of the variables you compare. So these would all re ...
- XML5632 : Only one root element is allowed. Line: 1, Column 1
奇葩啊, 最后查出来是因为有一个svg文件名对不上...
- ASP.NET动态网站制作(20)-- C#(3)
前言:C#的第三节课,继续上次课的内容,依旧围绕基础的只是讲解. 内容: 1.StringBuilder类:由于string类一旦创建,则不能更改.如果做字符串拼凑的话,将会非常耗费空间,如: str ...
- PHP手机号码正则表达式
php用正则表达式判断手机号码的写法:从文章中匹配出所有的手机号就可以preg_match_all(),如果要检查用户输入的手机号是否正确可这样来检查:preg_match(). 用正则匹配手机号码的 ...
- POJ1942
Paths on a Grid Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 24236 Accepted: 6006 ...
- react-native 使用 antd-mobile-rn UI进行开发app
1.创建 react-native 项目 react-native init app03 2.安装组件 npm install antd-mobile-rn --save 3.配置按需加载 npm i ...
- BZOJ1505: [NOI2004]小H的小屋
BZOJ1505: [NOI2004]小H的小屋 Description 小H发誓要做21世纪最伟大的数学家.他认为,做数学家与做歌星一样,第一步要作好包装,不然本事再大也推不出去. 为此他决定先在自 ...
- Tensorflow—gpu报错
一晚上什么事都没做,就一直在查找tensorflow1.4缺少cudnn64_6的错误. 最后发现自己一直用的是cudnn64_7,即使改成cudnn64_6仍不可行.主要受实验室大佬安装的cudnn ...