protected void grdState_RowUpdating(object sender, GridViewUpdateEventArgs e) { try { TextBox txtStateEdit = grdState.Rows[e.RowIndex].FindControl("txtStateEdit") as TextBox; HiddenField hdfStateid = grdState.Rows[e.RowIndex].FindControl("hdfStateid") as HiddenField; DropDownList ddlCountryE = grdState.Rows[e.RowIndex].FindControl("ddlCountryE") as DropDownList; CheckBox chkStatus = grdState.Rows[e.RowIndex].FindControl("chkStatus") as CheckBox; if (ddlCountryE.SelectedIndex == 0) { lblerrmsg.Text = "Please select country"; return; } if (txtStateEdit.Text.Length == 0) { lblerrmsg.Text = "State should not be empty"; return; } string status; if (chkStatus.Checked == true) { status = "Y"; } else { status = "N"; } int afctrows; objData = new MasterData(); TextInfo textInfo = cultureInfo.TextInfo; afctrows = objData.State_Update(textInfo.ToTitleCase(txtStateEdit.Text.Trim()), Convert.ToInt32(hdfStateid.Value.Trim()), Convert.ToInt32(ddlCountryE.SelectedItem.Value.Trim()), status); if (afctrows == 102) { lblerrmsg.Text = "State already exists."; return; } else if (afctrows == 103) { lblerrmsg.Text = "State can’t be deleted as is in use by an city"; return; } grdState.EditIndex = -1; grdfill(); divmsg.InnerHtml = "Record updated successfully."; (this.Master as Site1).ClearModifyStatus(); } catch (Exception ex) { throw ex; } }