关闭

List后台

408人阅读 评论(0) 收藏 举报
分类:

后台添加Confirm

for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                LinkButton LinkDel = (LinkButton)GridView1.Rows[i].FindControl("LinkDel");
                LinkDel.Attributes.Add("onclick", "return confirm('你要执行这个操作吗?');");

            }

全选

 for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                CheckBox ChkBxItem = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxDel");
                ChkBxItem.Checked = true;
            }

反选
 for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                CheckBox cb = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxDel");
                if (cb.Checked)
                {
                    cb.Checked = false;
                }
                else
                {
                    cb.Checked = true;
                }
            }
删除所选
StringBuilder del = new StringBuilder();
            int j = 0;
            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                CheckBox cb = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxDel");
                if (cb.Checked)
                {
                    HiddenField field = (HiddenField)GridView1.Rows[i].FindControl("CheckBoxDelValue");
                    if (j == 0)
                    {
                        del.Append(field.Value);
                    }
                    else
                    {
                        del.Append("," + field.Value);
                    }
                    j++;
                }
            }
            string imglist = del.ToString();
            if (!string.IsNullOrWhiteSpace(imglist))
            {
                imageBLL.DeleteList(imglist);
                GridView1.DataBind();
            }
GridView按钮事件后台处理
if (e.CommandName == "del")
            {
                imageBLL.Delete(new ImageModel(Convert.ToInt32(e.CommandArgument)));
                GridView1.DataBind();
            }

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场