protected void grdLookup_RowUpdating(object sender, GridViewUpdateEventArgs e) { try { TextBox txtlkup_descEdit = grdLookup.Rows[e.RowIndex].FindControl("txtlkup_descEdit") as TextBox; HiddenField hdflkup_id = grdLookup.Rows[e.RowIndex].FindControl("hdflkup_id") as HiddenField; DropDownList ddllkup_groupE = grdLookup.Rows[e.RowIndex].FindControl("ddllkup_groupE") as DropDownList; CheckBox chkStatus = grdLookup.Rows[e.RowIndex].FindControl("chkStatus") as CheckBox; //if (ddllkup_groupE.SelectedIndex == 0) //{ // lblerrmsg.Text = "Please select lookup group"; // return; //} if (txtlkup_descEdit.Text.Length == 0) { lblerrmsg.Text = "Lookup should not be empty"; return; } string status; if (chkStatus.Checked == true) { status = "Y"; } else { status = "N"; } int afctrows; objData = new MasterData(); string groupvalue = ddllkup_groupE.SelectedItem.Value.Split('|').GetValue(0).ToString(); int groupsize = Convert.ToInt32(ddllkup_groupE.SelectedItem.Value.Split('|').GetValue(1).ToString()); if (groupsize < txtlkup_descEdit.Text.ToString().Length) { lblerrmsg.Text = "Check lookup value length"; return; } TextInfo textInfo = cultureInfo.TextInfo; afctrows = objData.Lookup_Update(textInfo.ToTitleCase(txtlkup_descEdit.Text.Trim()), Convert.ToInt32(hdflkup_id.Value.Trim()), groupvalue, status); if (afctrows == 102) { lblerrmsg.Text = "Lookup already exists."; return; } grdLookup.EditIndex = -1; grdfill(); divmsg.InnerHtml = "Record updated successfully."; (this.Page.Master as Site1).ClearModifyStatus(); } catch (Exception ex) { showerror(ex); } }