);
while (myda.Read())
{
str.Append("<tr><td>");
str.Append("<input id=''checkItem_" + myda["ID"].ToString() + "'' type=''checkbox'' name=''checkItem'' style=''text-align=''left'' onclick='' NumberID()''/></td>");
str.Append("<td>" + myda["UserName"].ToString() + "</td>");
str.Append("<td>" + myda["FullName"].ToString() + "</td></tr>");
}
str.Append("</table>");
str.Append(" <div style='' text-align:center''><input type=''button'' value=''删除'' onclick=''DeleteUser()'' /></div>");
Response.Clear();
Response.ContentType = "application/text";
Response.Write(str);
Response.End();
}
/// <summary>
/// 周昕 2009-6-8 删除选中用户的详细信息
/// </summary>
public void DeleteUser()
{
//获取用户ID
string strID = Request["userid"];
string Userid = strID.Substring(0, strID.Length - 1);
//转换成为数组
string[] stridArray = Userid.Trim().Split('','');
string sql = "delete from loginuser where ID=''" + stridArray[0].ToString() + "''";
for (int i = 0; i < stridArray.Length; i++)
{
string id = stridArray[i].ToString();
sql += "or ID=''" + id + "''";
}
SqlConnection mycon = new SqlConnection();
mycon.ConnectionString = ConfigurationManager.ConnectionStrings["BoBoConn"].ToString();
mycon.Open();
SqlCommand mycom = new SqlCommand(sql, mycon);
int n = (int)mycom.ExecuteNonQuery();
mycon.Close();
if (n > 0)
{
Response.Clear();
Response.ContentType = "application/text";
Response.Write("ok");
Response.End();
}
else
{
Response.Clear();
Response.ContentType = "application/text";
Response.Write("no");
Response.End();
}
}
}
效果图: