void BindDeposits() { if (txtdate.Text == "") { txtdate.Text = "1/1/1900"; } if (txtrefno.Text == "") { txtrefno.Text = "1/1/1900"; } FlightBAL obj = new FlightBAL(); obj.FromDate = Convert.ToDateTime(txtdate.Text); obj.ToDate = Convert.ToDateTime(txtrefno.Text); obj.agentId = Convert.ToInt32(Session["UserId"]); DataSet ds = obj.GetFlightSalesReport(); if (ds != null) { if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { gvDeposits.DataSource = ds; gvDeposits.DataBind(); ViewState["gv"] = ds; trpaging.Visible = true; lblerrormsg.Visible = false; gvDeposits.Visible = true; } else { trpaging.Visible = false; lblerrormsg.Text = "No Data Found"; lblerrormsg.ForeColor = System.Drawing.Color.Red; lblerrormsg.Visible = true; gvDeposits.Visible = false; } } else { trpaging.Visible = false; lblerrormsg.Text = "No Data Found"; lblerrormsg.ForeColor = System.Drawing.Color.Red; lblerrormsg.Visible = true; gvDeposits.Visible = false; } } else { trpaging.Visible = false; lblerrormsg.Text = "No Data Found"; lblerrormsg.ForeColor = System.Drawing.Color.Red; lblerrormsg.Visible = true; gvDeposits.Visible = false; } if (txtdate.Text == "1/1/1900") { txtdate.Text = ""; } if (txtrefno.Text == "1/1/1900") { txtrefno.Text = ""; } }
protected void gvDeposits_Sorting(object sender, GridViewSortEventArgs e) { try { try { string strExpression = e.SortExpression; string strDirection = ViewState["SortDirection"].ToString(); FlightBAL objBal = new FlightBAL(); if (txtdate.Text == "") { txtdate.Text = "1/1/1900"; } if (txtrefno.Text == "") { txtrefno.Text = "1/1/1900"; } objBal.FromDate = Convert.ToDateTime(txtdate.Text); objBal.ToDate = Convert.ToDateTime(txtrefno.Text); DataSet ds = objBal.GetFlightSalesReport(); DataTable dt = ds.Tables[0]; DataView dv = new DataView(dt); dv.Sort = strExpression + strDirection; gvDeposits.DataSource = dv; gvDeposits.DataBind(); if (strDirection == " ASC") { ViewState["SortDirection"] = " DESC"; } else { ViewState["SortDirection"] = " ASC"; } if (txtdate.Text == "1/1/1900") { txtdate.Text = ""; } if (txtrefno.Text == "1/1/1900") { txtrefno.Text = ""; } } catch (Exception ex) { lblMsg.InnerHtml = ex.Message; throw; } } catch (Exception ex) { lblMsg.InnerHtml = ex.Message; throw; } }