protected void gvShippingByWeightAndCountry_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "UpdateShippingByWeightAndCountry") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = gvShippingByWeightAndCountry.Rows[index]; HiddenField hfShippingByWeightAndCountryId = row.FindControl("hfShippingByWeightAndCountryId") as HiddenField; DropDownList ddlShippingMethod = row.FindControl("ddlShippingMethod") as DropDownList; DropDownList ddlCountry = row.FindControl("ddlCountry") as DropDownList; DecimalTextBox txtFrom = row.FindControl("txtFrom") as DecimalTextBox; DecimalTextBox txtTo = row.FindControl("txtTo") as DecimalTextBox; CheckBox cbUsePercentage = row.FindControl("cbUsePercentage") as CheckBox; DecimalTextBox txtShippingChargePercentage = row.FindControl("txtShippingChargePercentage") as DecimalTextBox; DecimalTextBox txtShippingChargeAmount = row.FindControl("txtShippingChargeAmount") as DecimalTextBox; int shippingByWeightAndCountryId = int.Parse(hfShippingByWeightAndCountryId.Value); int shippingMethodId = int.Parse(ddlShippingMethod.SelectedItem.Value); int countryId = int.Parse(ddlCountry.SelectedItem.Value); ShippingByWeightAndCountry shippingByWeightAndCountry = ShippingByWeightAndCountryManager.GetById(shippingByWeightAndCountryId); if (shippingByWeightAndCountry != null) { ShippingByWeightAndCountryManager.UpdateShippingByWeightAndCountry(shippingByWeightAndCountry.ShippingByWeightAndCountryId, shippingMethodId, countryId, txtFrom.Value, txtTo.Value, cbUsePercentage.Checked, txtShippingChargePercentage.Value, txtShippingChargeAmount.Value); } BindData(); } }
protected void gvShippingByWeightAndCountry_RowDeleting(object sender, GridViewDeleteEventArgs e) { int shippingByWeightAndCountryId = (int)gvShippingByWeightAndCountry.DataKeys[e.RowIndex]["ShippingByWeightAndCountryId"]; ShippingByWeightAndCountry shippingByWeightAndCountry = ShippingByWeightAndCountryManager.GetById(shippingByWeightAndCountryId); if (shippingByWeightAndCountry != null) { ShippingByWeightAndCountryManager.DeleteShippingByWeightAndCountry(shippingByWeightAndCountry.ShippingByWeightAndCountryId); BindData(); } }