protected void btnDateEmp_Click(object sender, EventArgs e) { clearLabel(); //RESET DROPDOWN LISTS DropDownListSex.ClearSelection(); DropDmajorCategory.ClearSelection(); JTitWBranchDropBox.ClearSelection(); DropDownListJTBranch.ClearSelection(); DropDownListSexBr.ClearSelection(); DropDownListSbranch.ClearSelection(); JobTitleDropBox.ClearSelection(); dateStart.Text = ""; DateEnd.Text = ""; GridView1.DataSource = null; GridView1.DataBind(); GridView1.EmptyDataText = ""; string start = dateStart0.Text.Trim(); string end = DateEnd0.Text.Trim(); if (start != "" && end != "") { try { Convert.ToDateTime(start); Convert.ToDateTime(end); lblDatebirthError.Visible = false; EmployeeManager manage = new EmployeeManager(); DataTable result = manage.getDistrictEmployeeBasedOnDateEmployment(start, end); if (result != null && result.Rows.Count > 0) { GridView1.DataSource = result; GridView1.DataBind(); } } catch (FormatException) { GridView1.DataSource = null; GridView1.DataBind(); GridView1.EmptyDataText = ""; lblDatebirthError.Text = "Invalid Date value entered"; lblDatebirthError.Visible = true; lblDatebirthError.ForeColor = System.Drawing.Color.Red; } catch (Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); GridView1.EmptyDataText = ""; clearLabel(); msgPanel.Visible = true; ErroroDIV.Visible = true; lblErrorMsg.Text = "Something went wrong, Please contact your system administratot."; } } else { GridView1.DataSource = null; GridView1.DataBind(); GridView1.EmptyDataText = ""; btnExcel.Visible = false; lblDatebirthError.Text = "Date Interval can't be empty"; lblDatebirthError.Visible = true; lblDatebirthError.ForeColor = System.Drawing.Color.Red; } }