通过AJAX与ASP.NET结合实现的仿GridView增删改查功能!
jQurey代码部分:
创新互联-专业网站定制、快速模板网站建设、高性价比蒲县网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式蒲县网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖蒲县地区。费用合理售后完善,十载实体公司更值得信赖。
HTML代码部分:
SupplyAJAX类
- public partial class SupplyAJAX : System.Web.UI.Page
- {
- static List
UmList = new List (); - protected void Page_Load(object sender, EventArgs e)
- {
- switch (Request.QueryString["type"])
- {
- case "add":
- Add();
- break;
- case "update":
- Update();
- break;
- case "delete":
- Delete();
- break;
- }
- Response.End();
- }
- private string Add()
- {
- UserModel um = new UserModel();
- um.Id = UmList.Count + 1; //自动为ID加1
- um.Username = Request.Form["username"];
- um.Seltype = Request.Form["seltype"];
- UmList.Add(um);
- return um.Id.ToString();
- }
- private string Update()
- {
- int id = int.Parse(Request.QueryString["id"]);
- for (int i = 0; i < UmList.Count; i++)
- {
- if (id == UmList[i].Id)
- {
- UmList[i].Username = Request.Form["username"];
- UmList[i].Seltype = Request.Form["seltype"];
- return UmList[i].Id.ToString();
- }
- }
- return "0";
- }
- private string Delete()
- {
- int id = int.Parse(Request.Form["id"]);
- for (int i = 0; i < UmList.Count; i++)
- {
- if (id == UmList[i].Id)
- {
- UmList.Remove(UmList[i]);
- return UmList[i].Id.ToString();
- }
- }
- return "0";
- }
- }
附件:http://down.51cto.com/data/2359030
网站栏目:通过AJAX与ASP.NET结合实现的仿GridView增删改查功能!
网页URL:http://azwzsj.com/article/ihdgjs.html