62,041
社区成员
发帖
与我相关
我的任务
分享
private void BindDDL1()
{
//操作 删除and隐藏文章
this.DropDownList1.Items.Add(new ListItem("请选择批量操作", "0"));
this.DropDownList1.Items.Add(new ListItem("删除", "1"));
this.DropDownList1.Items.Add(new ListItem("隐藏", "2"));
}
protected void btnBatch_Click(object sender, EventArgs e)
{
//以下是批量操作
string ids = string.Empty;
foreach (GridViewRow row in this.GridView1.Rows)
{
CheckBox chk = row.FindControl("chk") as CheckBox;
if (chk.Checked)
{
HiddenField hid = row.FindControl("hid1") as HiddenField;
ids += hid.Value + ",";
}
}
if (ids == "" || ids == null) //获取选中的ID
{
//判断有无选中文章
Response.Write("<script>alert('您没有选择要操作的文章!')</script>");
}
else
{
//判断选中的是“删除”还是“隐藏”
if (Convert.ToInt32( this.DropDownList1.SelectedValue) == 0)
{
Response.Write("<script>alert('请问你要删除还是隐藏?')</script>");
}
else if (Convert.ToInt32(this.DropDownList1.SelectedValue) == 1)
{
this.btnBatch.Attributes.Add("onclick", "return confirm('" + this.DropDownList1.SelectedValue + "?');");
}
else
{
Response.Write("<script>alert('隐藏')</script>");
}
}
}