js代码:
<script type="text/javascript">
//全选/反选</script>
.aspx代码:
<asp:LinkButton ID="lbtn_UpdateUser" ForeColor="White" runat="server" OnClientClick="return ConfirmUpdate()"
OnClick="lbtn_UpdateUser_Click">Batch Update | </asp:LinkButton>
<asp:LinkButton ID="lbtn_DeleteUser" ForeColor="White" runat="server" OnClientClick="return ConfirmDelete()"
OnClick="lbtn_DeleteUser_Click">Delete</asp:LinkButton>
或者在.aspx.cs代码里这样写:
//删除代码:
string[] cbvalue = Request["CB_Group"].Split(',');
for (int i = 0; i < cbvalue.Length; i++)
{
string userid = cbvalue[i];
int uid = Convert.ToInt32(userid);
if (FieldValueDB.DelByUid(uid) > 0)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "result", "alert('Delete successfully!');", true);
BindFieldName();//重新绑定GridView
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "result", "alert('Failed to delete!');", true);
}
}
//修改代码
/// <summary>
/// 将数组转换为字符串
/// </summary>
/// <param name="arr"></param>
/// <returns></returns>
public string getString(string[] arr)
{
string str = "";
for (int i = 0; i < arr.Length; i++)
{
str = str + arr[i] + ",";
}
str = str.Substring(0, str.Length - 1);
return str;
}
try
{
string[] cbid = Request["CB_Group"].Split(',');
Session["cbuserid"] = getString(cbid);
}
catch (Exception)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "result", "alert('Please choose at least one');", true);
return;
}
Response.Redirect("UpdateUserInfo.aspx");