protected void btnSubmit_Click(object sender, EventArgs e) { if (txtAinTypeName_RQD.Text == "") { lblStatusMessage.Text = "ऐनको किसिम लेख्नुस"; programmaticModalPopup.Show(); return; } int ainType = 0; if (lstAinType.SelectedIndex != -1) { ainType = int.Parse(lstAinType.SelectedValue); } foreach (ListItem lst in lstAinType.Items) { if (lst.Selected == true) { continue; } if (lst.Text.Trim().ToLower() == txtAinTypeName_RQD.Text.Trim().ToLower()) { this.lblStatusMessage.Text = "Ain Type Already Exists"; this.programmaticModalPopup.Show(); return; } } ATTAinType objAinType = new ATTAinType(ainType, this.txtAinTypeName_RQD.Text.Trim(), this.chkActive.Checked == true ? "Y" : "N"); objAinType.EntryBy = strUser; if (this.lstAinType.SelectedIndex > -1) { objAinType.Action = "E"; } else { objAinType.Action = "A"; } try { List <ATTAinType> ListAinTypeList = (List <ATTAinType>)Session["AinType"]; BLLAinType.SaveAinType(objAinType); if (this.lstAinType.SelectedIndex > -1) { ListAinTypeList[this.lstAinType.SelectedIndex].AinTypeID = objAinType.AinTypeID; ListAinTypeList[this.lstAinType.SelectedIndex].AinTypeName = objAinType.AinTypeName; ListAinTypeList[this.lstAinType.SelectedIndex].Active = objAinType.Active; } else { ListAinTypeList.Add(objAinType); } ClearControls(); this.lstAinType.DataSource = ListAinTypeList; this.lstAinType.DataBind(); this.lblStatusMessage.Text = "Ain Type Successfully Saved."; this.programmaticModalPopup.Show(); } catch (Exception ex) { this.lblStatusMessage.Text = ex.Message; this.programmaticModalPopup.Show(); } }