GridView Paging Problem
-
hello friends, I am using a button to Generate a dataset and DataBind the dataset to a GridView.. But when paging is enabled to the GridView and when we click on page numbers i have to click the button again to display the data again... whether i have to write some Code in PageIndexCahnged or Changing??? My Button Click Event is Like This protected void cmdSearchAll_Click(object sender, EventArgs e) { gvCandidates.Visible = true; // ProcessSelectAllCandidates is a Process From Business Logic Layer Which Will Generate a DataSet When Invoked(in try block) Then the DataSet (ie.ResultSet) is assigned as DataSource to GridView ProcessSelectAllCandidates allcandidates = new ProcessSelectAllCandidates(); try { allcandidates.Invoke(); } catch { Response.Redirect("~/ErrorPage.htm"); } gvCandidates.DataSource = allcandidates.ResultSet; gvCandidates.DataBind(); } what will be the problem?? thanks in advance regards your friend
faz
-
hello friends, I am using a button to Generate a dataset and DataBind the dataset to a GridView.. But when paging is enabled to the GridView and when we click on page numbers i have to click the button again to display the data again... whether i have to write some Code in PageIndexCahnged or Changing??? My Button Click Event is Like This protected void cmdSearchAll_Click(object sender, EventArgs e) { gvCandidates.Visible = true; // ProcessSelectAllCandidates is a Process From Business Logic Layer Which Will Generate a DataSet When Invoked(in try block) Then the DataSet (ie.ResultSet) is assigned as DataSource to GridView ProcessSelectAllCandidates allcandidates = new ProcessSelectAllCandidates(); try { allcandidates.Invoke(); } catch { Response.Redirect("~/ErrorPage.htm"); } gvCandidates.DataSource = allcandidates.ResultSet; gvCandidates.DataBind(); } what will be the problem?? thanks in advance regards your friend
faz
Hi Faz, For my case, i will write a code in PageChanging. protected void GridView1_PageChanging(object sender, GridViewPageEventArgs e) { GridView gv = (GridView)sender; gv.PageIndex = e.NewPageIndex; //Bind the data to the GridView again } I have no idea if this is the problem that you have. Regards, Henri
-
Hi Faz, For my case, i will write a code in PageChanging. protected void GridView1_PageChanging(object sender, GridViewPageEventArgs e) { GridView gv = (GridView)sender; gv.PageIndex = e.NewPageIndex; //Bind the data to the GridView again } I have no idea if this is the problem that you have. Regards, Henri
hi henri, i have tried the code u gave..But still it is not working When i Click the Button to Display the GridView result it is coming.But When i click a Different page(Pagining Enabled) in the gridview i hav to clik the button again to view results from that particular page.. Coded like this in GridViewPageIndexChanging GridView gv = (GridView)sender; gv.PageIndex = e.NewPageIndex; dvCandidate.Visible = false; gvCandidates.Visible = true; ProcessSelectAllCandidates allcandidates = new ProcessSelectAllCandidates(); try { allcandidates.Invoke(); } catch { Response.Redirect("~/ErrorPage.htm"); } gv.DataSource = allcandidates.ResultSet; gv.DataBind();
faz
-
hello friends, I am using a button to Generate a dataset and DataBind the dataset to a GridView.. But when paging is enabled to the GridView and when we click on page numbers i have to click the button again to display the data again... whether i have to write some Code in PageIndexCahnged or Changing??? My Button Click Event is Like This protected void cmdSearchAll_Click(object sender, EventArgs e) { gvCandidates.Visible = true; // ProcessSelectAllCandidates is a Process From Business Logic Layer Which Will Generate a DataSet When Invoked(in try block) Then the DataSet (ie.ResultSet) is assigned as DataSource to GridView ProcessSelectAllCandidates allcandidates = new ProcessSelectAllCandidates(); try { allcandidates.Invoke(); } catch { Response.Redirect("~/ErrorPage.htm"); } gvCandidates.DataSource = allcandidates.ResultSet; gvCandidates.DataBind(); } what will be the problem?? thanks in advance regards your friend
faz
-
protected void cmdSearchAll_Click(object sender, EventArgs e) { gv.PageIndex=e.NewPageIndex; gv.DataBind(); } apply this code...
Naik M
Hi naik, How i will get e.NewPageIndex in buttonclick event??? i think u didnt got my problem..Actucally my problem is like. i am using a button to fill the GridView. when paging is enabled and Click the button it will show the result.. But when we change the gridview page(say page2), i have to click the Button again to view the second page... please give me a solution it is urgent regards
faz