Example #1
0
        // route the formview command to the correct data action -- [email protected] -- 11022017
        protected void frmCityArea_ItemCommand(object sender, FormViewCommandEventArgs e)
        {
            TextBox txtCityAreaName = (TextBox)frmCityArea.FindControl("txtCityAreaName");
            TextBox txtCityAreaCode = (TextBox)frmCityArea.FindControl("txtCityAreaCode");

            MDMSVC.DC_CityArea _obj = new MDMSVC.DC_CityArea();

            _obj.City_Id = Guid.Parse(Convert.ToString(Request.QueryString["City_Id"]));
            _obj.Name    = txtCityAreaName.Text.Trim();
            _obj.Code    = txtCityAreaCode.Text.Trim();
            if (Convert.ToString(e.CommandName) == "Add")
            {
                _obj.CityArea_Id = Guid.NewGuid();
                _obj.Option      = "Save";
                _objMasterData.SaveCityArea(_obj);



                fillCityArea(Request.QueryString["City_Id"]);
                txtCityAreaName.Text = "";
                txtCityAreaCode.Text = "";
                frmCityArea.ChangeMode(FormViewMode.Insert);
            }
            else if (Convert.ToString(e.CommandName) == "Save")
            {
                _obj.CityArea_Id = Guid.Parse(Convert.ToString(grdCityAreas.SelectedDataKey.Value));
                _obj.Option      = "UPDATE";
                _objMasterData.SaveCityArea(_obj);

                fillCityArea(Request.QueryString["City_Id"]);
                txtCityAreaName.Text = "";
                txtCityAreaCode.Text = "";
                frmCityArea.ChangeMode(FormViewMode.Insert);
            }
        }