Click here to Skip to main content
15,908,013 members
Please Sign up or sign in to vote.
1.44/5 (3 votes)
See more:
C#
protected void Button1_Click(object sender, EventArgs e)
  {
      if (FileUpload1.PostedFile.FileName == string.Empty)
      {
          lblMsg.Visible = true;
          return;
      }
      else
      {
          string[] FileExt = FileUpload1.FileName.Split('.');
          string FileEx = FileExt[FileExt.Length - 1];
          if (FileEx.ToLower() == "csv")
          {
           FileUpload1.SaveAs(Server.MapPath("CSVLoad//" + FileUpload1.FileName));
           lblMsg.Visible = false;
          }
          else
          {
              lblMsg.Visible = true;
              return;
          }
      }
      CSVReader reader = new CSVReader(FileUpload1.PostedFile.InputStream);
      string[] headers = reader.GetCSVLine();
      DataTable dt = new DataTable();
      foreach (string strHeader in headers)
          dt.Columns.Add(strHeader);
      string[] data;
      while ((data = reader.GetCSVLine()) != null)
      dt.Rows.Add(data);
      gv.DataSource = dt;
      gv.DataBind();
  }

C#
protected void gv_PageIndexChanging(object sender, GridViewPageEventArgs e)
       {
          // please provide a code for grid page index changing


       }
Posted
Updated 12-Feb-14 21:30pm
v3
Comments
CBadger 6-Feb-14 2:21am    
What is the question exactly?
siva Prasad Paruchuri 13-Feb-14 3:28am    
provide a code for Grid view Page Index Changing.....
protected void gv_PageIndexChanging(object sender, GridViewPageEventArgs e)
{



}
[no name] 6-Feb-14 5:02am    
ZurdoDev 6-Feb-14 8:16am    
Where are you stuck?
I guess you have rejected my answer by mistake after accepting it.
In that case, please accept and up-vote.

Thanks,
Tadit

Go through some articles suggested by Google[^] and learn yourself.

If you face any difficulty while coding, feel free to come back here and ask another question with specific issue describing the scenario.
 
Share this answer
 
C#
protected void gv_PageIndexChanging(object sender, GridViewPageEventArgs e)
       {
        //redo Databind() here as below or call a void using ViewState to carry e.NewPageIndex  inserting the "gv.PageIndex directly after DataBind()
        gv.DataBind();
        gv.PageIndex = e.NewPageIndex;
        }
 
Share this answer
 
v3
Not sure what precisely you are looking for.
But PageIndexChanged event needs the PageIndex to be set to new index and then Bind the GridView for the Pagination to work.

Refer

gridview.pageindexchanging[^]

implement-paging-and-sorting-in-aspnet-Gridview-[^]

Implement-Pagination-in-ASP.Net-Gridview-Control[^]
 
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