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(); }
protected void gv_PageIndexChanging(object sender, GridViewPageEventArgs e) { // please provide a code for grid page index changing }
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; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)