jquery控制动态生成的gridview中多列checkbox的全选反选及自动判断是否全选状态
动态生成的Gridview的前台html代码如下:
public class UpdateStatus : IHttpHandler { public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; int isChecked = context.Request["isChecked"] == "checked" ? 1 : 0; string colId=context.Request["id"]; string name = colId.Substring(colId.LastIndexOf('_')+1, colId.Length - colId.LastIndexOf('_')-1); int result=0; if (QuarrysClass.CheckFlag.ToLower().IndexOf("@" + name + "@") != -1) { string selectStr = QuarrysClass.StrWhere; //控制前台刷新 result = EquSearchBll.equBll.UpdateAllChecked(name, isChecked, selectStr) == 1 ? 2 : EquSearchBll.equBll.UpdateAllChecked(name, isChecked, selectStr); } else { if (name.Contains('-')) { string idName = context.Request["fid"]; string[] arrays = name.Split('-'); string id = arrays[0]; if (string.IsNullOrEmpty(id)) //主键为空无法更新 { context.Response.Write("empty," + isChecked+"," + colId); return; } string fieldName = arrays[1]; string strWhere = string.Format(" and {0}='{1}'",idName,id); result = EquSearchBll.equBll.UpdateAllChecked(fieldName, isChecked, strWhere); } } context.Response.Write(result); } public bool IsReusable { get { return false; } } }