public void rdVendors_DeleteCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) { if (e.CommandName == "delete") { var v = new RecycleVendorEntity(Convert.ToInt32(e.CommandArgument)); v.IsActive = false; v.Save(); } }
protected void rdVendors_OnItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { DropDownList ddlType = e.Item.FindControl("ddlType") as DropDownList; if (ddlType != null) { RecycleVendorEntity v = e.Item.DataItem as RecycleVendorEntity; ddlType.SelectedValue = v.Type; } } }
protected void btnSaveVendor_Click(object sender, EventArgs e) { if (txtName.Text.Trim().Length > 0) { RecycleVendorEntity v = new RecycleVendorEntity(); v.Name = txtName.Text.Trim(); v.Type = ddlType.SelectedValue; v.Save(); txtName.Text = ""; txtName.Focus(); rdVendors.Rebind(); } }
protected void btnSaveVendorChanges_Click(object sender, EventArgs e) { foreach (GridDataItem vendorItem in rdVendors.Items) { Hashtable typeValues = new Hashtable(); vendorItem.ExtractValues(typeValues); int recycleVendorId = Convert.ToInt32(typeValues["RecycleVendorId"].ToString()); RecycleVendorEntity recycleVendor = new RecycleVendorEntity(recycleVendorId); TextBox txtName = vendorItem.FindControl("txtName") as TextBox; DropDownList ddlType = vendorItem.FindControl("ddlType") as DropDownList; recycleVendor.Name = txtName.Text.Trim().Length > 0 ? txtName.Text.Trim() : ""; recycleVendor.Type = ddlType.SelectedValue == "O" ? "Open-top Landfill" : "Landfill Compactor"; recycleVendor.Save(); } }