Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
i have one gridview of all employees with check box column.
when i check records, details of that employees comes in second grid view.
now, my first grid view paging works. but the second gridview paging do not work.
i have two problems.
1.when i check some records in first grid view and changes the page, the records displayed in the second gridview are only from current page. previous checks are refreshed. so how do i get those values in next gridview
2.in second grid view when i click to second page. the grid view disappears.

after adding a theme to gridview for paging i have added this code to first grid view
C#
protected void gvDetails_PageIndexChanging1(object sender, GridViewPageEventArgs e)
{
    gvDetails.PageIndex = e.NewPageIndex;

    string str1 = "SELECT ID, FirstName, LastName FROM EmpMaster";
    Command = new SqlCommand(str1, con);
    Command.CommandType = CommandType.Text;
    SqlDataAdapter da = new SqlDataAdapter(Command);
    da.Fill(dtLogin);

    gvDetails.DataSource = dtLogin;
    gvDetails.DataBind();
}

and, this doesnt works for second one,
C#
protected void gvDisplayRecords_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    gvDisplayRecords.PageIndex = e.NewPageIndex;
    gvDisplayRecords.DataSource = dtLogin;
    gvDisplayRecords.DataBind();
    gvDisplayRecords.Visible = true;
}

so please post the solution.......

[edit]Code block added, "Treat my content as plain text..." option disabled - OriginalGriff[/edit]
Posted
Updated 20-Feb-12 22:56pm
v2

1 solution

is the object dtLogin cached or so? I think the dtLogin is null. You better have the part
C#
string str1 = "SELECT ID, FirstName, LastName FROM EmpMaster";
        Command = new SqlCommand(str1, con);
        Command.CommandType = CommandType.Text;
        SqlDataAdapter da = new SqlDataAdapter(Command);
        da.Fill(dtLogin);

in 1 method that both current methods can use.

Try debug you code; set a breakpoint in method gvDisplayRecords_PageIndexChanging on line
C#
gvDisplayRecords.DataSource = dtLogin;

and see the value of dtLogin
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900