protected void saveNav_Click(object sender, EventArgs e) { int row = 0; foreach (object o in DataGrid1.GetKeyIDArray()) { int id = int.Parse(o.ToString()); string displayorder = DataGrid1.GetControlValue(row, "displayorder").Trim(); string url = DataGrid1.GetControlValue(row, "url").Trim(); NavInfo nav = Navs.GetNavigation(id); if (nav == null) { continue; } if (!Utils.IsNumeric(displayorder) || url == "") { row++; continue; } if (nav.Displayorder != int.Parse(displayorder) || nav.Url != url) { nav.Displayorder = int.Parse(displayorder); nav.Url = url; Navs.UpdateNavigation(nav); } row++; } Response.Redirect(Request.RawUrl, true); }
protected void Page_Load(object sender, EventArgs e) { DataGrid1.DataKeyField = "id"; string menuid = DNTRequest.GetString("menuid"); string mode = DNTRequest.GetString("mode"); if (mode != "") { if (mode == "del") { Navs.DeleteNavigation(DNTRequest.GetQueryInt("id", 0)); Response.Redirect(Request.Path + (DNTRequest.GetString("parentid") != "" ? "?parentid=" + DNTRequest.GetString("parentid") : ""), true); } else { if (DNTRequest.GetFormString("name").Trim() == "" || DNTRequest.GetFormString("displayorder").Trim() == "" || DNTRequest.GetFormInt("displayorder", 0) > Int16.MaxValue) { this.RegisterStartupScript("", "<script type='text/javascript'>alert('名称或序号输入不合法。');window.location=window.location;</script>"); return; } if (menuid == "0") { NavInfo nav = new NavInfo(); nav.Parentid = DNTRequest.GetQueryInt("parentid", 0); GetFromData(nav); Navs.InsertNavigation(nav); } else { NavInfo nav = new NavInfo(); nav.Id = DNTRequest.GetFormInt("menuid", 0); GetFromData(nav); Navs.UpdateNavigation(nav); } Response.Redirect(Request.RawUrl, true); } } else { BindDataGrid(DNTRequest.GetQueryInt("parentid", 0)); if (DNTRequest.GetString("parentid") == "") { returnbutton.Visible = false; } } }