Exemplo n.º 1
0
    protected void GridViewTimesheet_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridViewTimesheet.PageIndex = e.NewPageIndex;

        LoadTimesheet();

        GridViewTimesheet.DataBind();
    }
Exemplo n.º 2
0
    private void LoadTimesheet()
    {
        dt = new DataTable();

        string cnnstr = ConfigurationManager.AppSettings["ConnectionString"];

        SqlConnection conn = new SqlConnection(cnnstr);

        conn.Open();

        string Query = @"SELECT  dbo.ClientDetails.ClientID, dbo.ClientDetails.EmailAddress, dbo.Notes.UpdatedDate, dbo.Notes.SubscriberNotes
                             FROM  dbo.ClientDetails RIGHT OUTER JOIN
                            dbo.Notes ON dbo.ClientDetails.ClientID = dbo.Notes.ClientID
                            WHERE dbo.ClientDetails.EmailAddress is not null";

        adapt = new SqlDataAdapter(Query, conn);

        adapt.Fill(dt);

        if (dt.Rows.Count > 0)
        {
            GridViewTimesheet.DataSource = dt;

            GridViewTimesheet.DataBind();
        }

        else
        {
            dt.Rows.Add(dt.NewRow());

            GridViewTimesheet.DataSource = dt;

            GridViewTimesheet.DataBind();

            int TotalColumns = GridViewTimesheet.Rows[0].Cells.Count;

            GridViewTimesheet.Rows[0].Cells.Clear();

            GridViewTimesheet.Rows[0].Cells.Add(new TableCell());

            GridViewTimesheet.Rows[0].Cells[0].ColumnSpan = TotalColumns;

            GridViewTimesheet.Rows[0].Cells[0].Text = "No records Found";
        }

        conn.Close();
    }