Exemplo n.º 1
0
    protected void BindGridView()
    {
        try
        {
            if (lstSearchType.SelectedIndex == 0)
            {
                showHouseitem();
                GridViewHouse.Visible  = true;
                GridViewMaster.Visible = false;
                if (ds.Tables["HouseTable"].Rows.Count == 0)
                {
                    MakeEmptyGridView(GridViewHouse, "HouseTable");
                }
                else
                {
                    GridViewHouse.PageSize   = maxRows;
                    GridViewHouse.DataSource = ds.Tables["HouseTable"].DefaultView;
                    GridViewHouse.DataBind();

                    lblRecordCount.Text = ds.Tables["HouseTable"].Rows.Count + " records found.   Page "
                                          + (GridViewHouse.PageIndex + 1) + " / " + GridViewHouse.PageCount;
                }
            }
            else if (lstSearchType.SelectedIndex == 1)
            {
                hiddenHouseitem();
                GridViewHouse.Visible  = false;
                GridViewMaster.Visible = true;
                if (ds.Tables["MasterTable"].Rows.Count == 0)
                {
                    MakeEmptyGridView(GridViewMaster, "MasterTable");
                }

                else
                {
                    GridViewMaster.PageSize   = maxRows;
                    GridViewMaster.DataSource = ds.Tables["MasterTable"].DefaultView;
                    GridViewMaster.DataBind();

                    lblRecordCount.Text = ds.Tables["HouseTable"].Rows.Count + " records found.   Page "
                                          + (GridViewMaster.PageIndex + 1) + " / " + GridViewMaster.PageCount;
                }
            }
            ds.Dispose();
        }
        catch
        {
            Response.Write("<script>alert('Date Error. Please Check the Date and Try again'); self.close();</script>");
            Response.Write("<script>window.history.back();</script>");
        }
    }
Exemplo n.º 2
0
    protected void BindGridView()
    {
        if (lstSearchType.SelectedIndex == 0)
        {
            showhawbitem();
            GridViewHouse.Visible  = true;
            GridViewMaster.Visible = false;
            if (ds.Tables["HouseTable"].Rows.Count == 0)
            {
                MakeEmptyGridView(GridViewHouse, "HouseTable");
            }
            else
            {
                GridViewHouse.PageSize   = maxRows;
                GridViewHouse.DataSource = ds.Tables["HouseTable"].DefaultView;
                GridViewHouse.DataBind();
                lblRecordCount.Text = ds.Tables["HouseTable"].Rows.Count + " records found.&nbsp;&nbsp;&nbsp;Page "
                                      + (GridViewHouse.PageIndex + 1) + " / " + GridViewHouse.PageCount;
                btnExcelExport.Visible = true;
            }
        }
        else if (lstSearchType.SelectedIndex == 1)
        {
            hiddenhawbitem();
            GridViewHouse.Visible  = false;
            GridViewMaster.Visible = true;
            if (ds.Tables["MasterTable"].Rows.Count == 0)
            {
                MakeEmptyGridView(GridViewMaster, "MasterTable");
            }

            else
            {
                GridViewMaster.PageSize   = maxRows;
                GridViewMaster.DataSource = ds.Tables["MasterTable"].DefaultView;
                GridViewMaster.DataBind();
                lblRecordCount.Text = ds.Tables["MasterTable"].Rows.Count + " records found.&nbsp;&nbsp;&nbsp;Page "
                                      + (GridViewMaster.PageIndex + 1) + " / " + GridViewMaster.PageCount;
                btnExcelExport.Visible = true;
            }
        }
        ds.Dispose();
    }
Exemplo n.º 3
0
    protected void btnExcelExport_Click(object sender, EventArgs e)
    {
        string attachment = "attachment; filename=SearchResult.xls";

        Response.ClearContent();
        Response.AddHeader("content-disposition", attachment);
        Response.ContentType = "application/ms-excel";
        StringWriter   sw  = new StringWriter();
        HtmlTextWriter htw = new HtmlTextWriter(sw);

        if (lstSearchType.SelectedIndex == 0)
        {
            GridViewHouse.RenderControl(htw);
        }
        else if (lstSearchType.SelectedIndex == 1)
        {
            GridViewMaster.RenderControl(htw);
        }
        Response.Write(sw.ToString());
        Response.End();
    }