protected void btnSizeSubmit_Click(object sender, EventArgs e) { try { if (ViewState["NewSizesCounter"] != null && tvCats.SelectedNode != null) { using (CatalogDataContext dct = new CatalogDataContext()) { int counter = int.Parse(ViewState["NewSizesCounter"].ToString()); for (int i = 0; i < counter; i++) { Label lbl = (Label)this.Master.FindControl("MainContent").FindControl("lblSize" + i); DropDownList ddl = (DropDownList)this.Master.FindControl("MainContent").FindControl("ddlSize" + i); Mapping_Size mSize = new Mapping_Size() { id = System.Guid.NewGuid(), ss_size_name = lbl.Text, tb_size_name = ddl.SelectedItem.Text, tb_vid = long.Parse(ddl.SelectedValue), tb_cid = long.Parse(tvCats.SelectedValue) }; dct.Mapping_Sizes.InsertOnSubmit(mSize); } dct.SubmitChanges(); } } else throw new ArgumentNullException("ViewState中没有NewSizesCounter,或者ViewState中没有TBCid"); } catch (Exception ex) { string message = ex.Message.Replace("\n", "\\n").Replace("\r", "").Replace("'", "\\'"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('" + message + "')", true); } }
partial void UpdateMapping_Size(Mapping_Size instance);
partial void DeleteMapping_Size(Mapping_Size instance);
partial void InsertMapping_Size(Mapping_Size instance);