private void BindGrid() { PurchaseBillDAL obj = new PurchaseBillDAL(); DateTime? datefromValue = null; DateTime? dateToValue = null; Int64 yearIDNO = Convert.ToInt32(ddlDateRange.SelectedValue); int BillNo = string.IsNullOrEmpty(Convert.ToString(txtBillNo.Text)) ? 0 : Convert.ToInt32(txtBillNo.Text); Int32 purType = Convert.ToInt32(ddlPurchaseType.SelectedValue); if (string.IsNullOrEmpty(Convert.ToString(Datefrom.Text)) == false) { datefromValue = Convert.ToDateTime(ApplicationFunction.mmddyyyy(Datefrom.Text)); } if (string.IsNullOrEmpty(Convert.ToString(txtDateTo.Text)) == false) { dateToValue = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateTo.Text)); } int cityfrom = Convert.ToInt32(drpCityFrom.SelectedValue); int sender = Convert.ToInt32(ddlSender.SelectedValue == "" ? 0 : Convert.ToInt32(ddlSender.SelectedValue)); Int32 yearidno = Convert.ToInt32(ddlDateRange.SelectedValue == "" ? 0 : Convert.ToInt32(ddlDateRange.SelectedValue)); Int64 UserIdno = 0; if (Convert.ToString(Session["Userclass"]) != "Admin") { UserIdno = Convert.ToInt64(Session["UserIdno"]); } var lstGridData = obj.Select_PurchaseBillDetailList(BillNo, datefromValue, dateToValue, cityfrom, sender, yearidno, UserIdno, purType); obj = null; if (lstGridData != null && lstGridData.Count > 0) { grdMain.DataSource = lstGridData; grdMain.DataBind(); lblTotalRecord.Text = "T. Record (s): " + lstGridData.Count; imgBtnExcel.Visible = false; prints.Visible = false; Double TotalNetAmount = 0; for (int i = 0; i < lstGridData.Count; i++) { TotalNetAmount += Convert.ToDouble(DataBinder.Eval(lstGridData[i], "Net_Amnt")); } lblNetTotalAmount.Text = TotalNetAmount.ToString("N2"); int startRowOnPage = (grdMain.PageIndex * grdMain.PageSize) + 1; int lastRowOnPage = startRowOnPage + grdMain.Rows.Count - 1; lblcontant.Text = "Showing " + startRowOnPage.ToString() + " - " + lastRowOnPage.ToString() + " of " + lstGridData.Count.ToString(); lblcontant.Visible = true; divpaging.Visible = true; } else { grdMain.DataSource = null; grdMain.DataBind(); lblTotalRecord.Text = "T. Record (s): 0 "; lblcontant.Visible = false; divpaging.Visible = false; imgBtnExcel.Visible = false; prints.Visible = false; } }