I have a Grid Web Object on my ASP.Net form, along with an asp.net fileupload control to get the filename I want to upload. I locate and upload a spreadsheet that contains 3 worksheets into my Grid Web Object. That works very well. I can even edit the data.
But, when I hit the 'Save' button, I have no clue what to do to get the data from the current worksheet into a SQL table. I can't even figure out how to tell which worksheet I'm on. If you could post some clear, readable sample code in VB.Net that takes the data from a single worksheet (the currently selected tab) and inserts each row and column (say the first 25 columns) into a SQL table, I'd appreciate it. Let's assume we have a table called tblImport that has just 26 columns (25 for the data and one for an identity column). The columns are called ImportID, F1, F2, F3 . . . F25. How do I get the data from the worksheet into this table?
I'm not even able to get the code you see below to work to save any changes I made to the data while it was displayed on the screen, back to the Excel file itself. What am I doing wrong? Please let me know.
Partial Class Inventory_Update
Public ExcelFileName As String
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
ExcelFileName = FileUpload1.PostedFile.FileName 'asp.net fileupload control lets you browse
Label1.Text = ExcelFileName 'just to see the full pathname
Protected Sub GridWeb1_SaveCommand(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridWeb1.SaveCommand