I am uploading an excel spreadsheet to a gridview using a datatable and storing the excel data into the datatable. however, due to pagination i am unable to get the name of every row under my gridview column when i use
(GridView1.Rows(i).Cells(x).Text.ToString
. i am doing an arraylist.add property on each row under column 1 however only the first page shows up but not the rest. Furthermore, when i add the datatable to a global variable class object which is also a datatable it is unable to read it in another function. I am not sure as to why this is occuring.
Public Class GlobalVariable
Public Shared Dttbl As New DataTable
End Class
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Call loadExcel()
Call callGlobalVariable()
End If
End Sub
Public Function loadExcel()
Dim MyConnection As System.Data.OleDb.OleDbConnection
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
Dim taskTable As New DataTable
Dim filePath = Path.Combine(GlobalVariable.savedPath, GlobalVariable.excelFileName)
If File.Exists(filePath) Then
MyConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & filePath & ";Extended Properties='Excel 12.0 Xml;HDR=YES;';")
MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", MyConnection)
MyCommand.Fill(taskTable)
GlobalVariable.Dttbl = taskTable.Copy
Session("TaskTable") = taskTable
BindData()
MyConnection.Close()
Return Nothing
End Function
another function i am creating like this and i am trying to call the globalvariable
Public Function callGlobalVariable()
GlobalVariable.Dttbl.Rows(0).ItemArray(0).ToString()
Return Nothing
End Function
What I have tried:
I have tried the following code above but its giving me issues not sure what to do now.