示例#1
0
 /// <summary>
 /// Name:Bindgrid
 /// Description:Bind the grid if datatable is blank then it displays message in label
 /// Author:Monal Shah
 /// created Date:2010/10/21
 /// </summary>
 public void BindGrid()
 {
     try
     {
         objSbSelect = new StringBuilder();
         objSbSelect.Append("Select ");
         objSbSelect.Append("* ");
         objSbSelect.Append("From ");
         objSbSelect.Append("TblEmployee");
         objcl.GetSqlStmt = objSbSelect.ToString();
         objDt            = objcl.DataTables();
         if (objDt.Rows.Count > 0)
         {
             objDv = new DataView(objDt);
             this.EmployeeGrid.DataSource = objDv;
             this.EmployeeGrid.DataBind();
             ViewState["dt"] = objDt;
         }
         else
         {
             LblMsg.Visible         = true;
             BtnDisplayGrid.Visible = false;
             EmployeeGrid.Visible   = false;
             LblMsg.Text            = ConstantMessage.NoRecord;
         }
     }
     catch (Exception)
     {
         Response.Redirect("Error.aspx", false);
     }
     finally
     {
         objSbSelect = null;
         objcl       = null;
         objDt.Dispose();
     }
 }
示例#2
0
        /// <summary>
        /// Name:Bindgrid
        /// Description:Bind the repeater and datalist if datatable is blank then it displays message in label
        /// Author:Monal Shah
        /// created Date:2010/10/22
        /// </summary>
        public void BindGrid()
        {
            try
            {
                objSbSelect = new StringBuilder();
                objSbSelect.Append("Select ");
                objSbSelect.Append("* ");
                objSbSelect.Append("From ");
                objSbSelect.Append("TblEmployee");
                objcl.GetSqlStmt         = objSbSelect.ToString();
                objDt                    = objcl.DataTables();
                objDv                    = new DataView(objDt);
                objDv.Sort               = DdlSort.SelectedItem.Value.ToString() + " " + ASCENDING;
                pgitems                  = new PagedDataSource();
                pgitems.DataSource       = objDv;
                pgitems.AllowPaging      = true;
                pgitems.PageSize         = 5;
                pgitems.CurrentPageIndex = PageNumber;
                _pgCount                 = pgitems.PageCount;
                if (objDt.Rows.Count > 0)
                {
                    if (pgitems.PageCount > 1)
                    {
                        pages = new ArrayList();
                        for (int i = 0; i < pgitems.PageCount; i++)
                        {
                            pages.Add((i + 1).ToString());
                        }
                        LblPageNo.Text = string.Format(ConstantMessage.ViewingMsg, pgitems.CurrentPageIndex + 1, pgitems.PageCount);

                        BtnPrevious.Enabled = !pgitems.IsFirstPage;
                        BtnNext.Enabled     = !pgitems.IsLastPage;

                        this.EmployeeRepeater.DataSource = pgitems;
                        this.EmployeeRepeater.DataBind();
                        this.EmployeeDataList.DataSource = pgitems;
                        this.EmployeeDataList.DataBind();
                    }
                }
                else
                {
                    LblMsg.Visible           = true;
                    EmployeeRepeater.Visible = false;
                    EmployeeDataList.Visible = false;
                    TblRepeater.Visible      = false;
                    LblMsg.Text         = ConstantMessage.NoRecord;
                    BtnPrevious.Visible = false;
                    BtnNext.Visible     = false;
                    BtnFirst.Visible    = false;
                    BtnLast.Visible     = false;
                }
            }
            catch (Exception)
            {
                Response.Redirect("Error.aspx", false);
            }
            finally
            {
                objSbSelect = null;
                objcl       = null;
                objDt.Dispose();
            }
        }