//Create Date Rows #region [Date Row] protected void DateRows() { try { if (txtFrom.Text != "" && txtTo.Text != "") { GrdLeaveApplication.DataSource = null; GrdLeaveApplication.DataBind(); DataTable dtDate = new DataTable(); dtDate.Columns.Add("Date"); dtDate.Columns.Add("Full_Half"); dtDate.Columns.Add("LeaveType"); DateTime start = DateTime.ParseExact(txtFrom.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); //DateTime st=DateTime.Parse( DateTime end = DateTime.ParseExact(txtTo.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); for (DateTime s = start; s <= end; s = s.AddDays(1)) { dtDate.Rows.Add((s.ToString("dd/MM/yyyy")).Replace('-', '/'), "1", "0"); } GrdLeaveApplication.DataSource = dtDate; GrdLeaveApplication.DataBind(); } } catch (Exception exp) { GeneralErr(exp.Message); } }
void clear() { txtFrom.Text = ""; txtTo.Text = ""; txtReason.Text = ""; GrdLeaveApplication.DataSource = null; GrdLeaveApplication.DataBind(); }
//Bind Empty Grid #region [Bind Empty Grid] public void BindEmptyGrid() { try { DataTable dt = new DataTable(); GrdLeaveApplication.DataSource = dt; GrdLeaveApplication.DataBind(); } catch (Exception exp) { GeneralErr(exp.Message); } }