By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,200 Members | 1,761 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,200 IT Pros & Developers. It's quick & easy.

Get input from spreadsheet control to server for processing

P: n/a
Hi all,

I'm new to asp.net, and using Visual Web Dev express. As such I cannot
see the spreadsheet control and directly access the object properties
from the VB code in the back of my page.
I have declared it as an object as follows:
<object classid="clsid:0002E559-0000-0000-C000-000000000046"
id="Spreadsheet1" name="Spreadsheet1" style="width: 331px; height:
215px" >
note: all users have Office 2003 Web Components
Can only interact with this user entered data client-side, via
"document.all.item("Spreadsheet1").csvdata"
<input type=hidden id="TextBox1" name="TextBox1" />
Can only use this client side, so I can't get the contents of
spreadsheet in here and use it on the server. (If someone knows how it
can be done, please share )
<asp:TextBox ID="TextBox2" runat="server" TextMode="MultiLine"
AutoPostBack="True" Height="76px" Width="99px"
Visible="false"></asp:TextBox>
This is an asp box, so users can interact with, but it is not
recognized in client side vbscript. It works if I make it visible and
paste directly.
I was also unsuccessful at getting a javascript function to recognize
this textbox. I kept getting "Object Required" errors.
What I am trying to do is get the csvdata into my temp table. I tried
to do it in the following function (VB on back) and it works if I can
get the data:
Private Sub fnBeforePaste(ByVal txtPassed As String)
Dim i As Int32
Dim Idata() As String = Split(txtPassed, Chr(13) & Chr(10))
'or use Environment.Newline
If InStr(txtPassed, Environment.NewLine) Then
MsgBox("Environment.Newline")
For i = 0 To Idata.GetUpperBound(0) - 1
Dim stCells() As String = Split(Idata(i), Chr(9)) 'or
use ',' for csvdata
stCells(0) = Replace(stCells(0), Chr(10), "")
If Len(stCells(0)) < 2 Then GoTo ExitPasteGrid
AccessDataSource2.InsertCommand = "INSERT INTO Temptbl
(ESN,[MIN]) SELECT '" & stCells(0) & "' AS Expr1, '" & stCells(1) & "'
AS Expr2;"
'"INSERT INTO Temptbl ( ESN, [MIN] ) SELECT " & stCells(0)
& "," & stCells(1)
AccessDataSource2.Insert()
Next
ExitPasteGrid:
'TextBox2.Text = ""
GridEntry.DataBind()
End Sub
This way I can run a query in the database, and return the query
results in a second grid on the page. I have to use something easy for
users to enter two columns of unknown rows of numerical text values in
a temp table in order to join it to the other query table.
Any suggestions on how to approach this problem are much appreciated.
:)

Dec 6 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a


On 6 Dec 2006 11:26:34 -0800, "aspiring geek" <so*************@yahoo.comwrote:
>Hi all,

I'm new to asp.net, and using Visual Web Dev express. As such I cannot
see the spreadsheet control and directly access the object properties
from the VB code in the back of my page.
I have declared it as an object as follows:
<object classid="clsid:0002E559-0000-0000-C000-000000000046"
id="Spreadsheet1" name="Spreadsheet1" style="width: 331px; height:
215px" >
note: all users have Office 2003 Web Components
Can only interact with this user entered data client-side, via
"document.all.item("Spreadsheet1").csvdata"
<input type=hidden id="TextBox1" name="TextBox1" />
Can only use this client side, so I can't get the contents of
spreadsheet in here and use it on the server. (If someone knows how it
can be done, please share )
Use Java Script:
TextBox1.value = aspnetForm.Spreadsheet1.csvData;
>

<asp:TextBox ID="TextBox2" runat="server" TextMode="MultiLine"
AutoPostBack="True" Height="76px" Width="99px"
Visible="false"></asp:TextBox>
This is an asp box, so users can interact with, but it is not
recognized in client side vbscript. It works if I make it visible and
paste directly.
I was also unsuccessful at getting a javascript function to recognize
this textbox. I kept getting "Object Required" errors.
In your client side Java Script Code you need to reference this object
by the Client Side ID that ASP.Net assigns to it:

var myTextBox = aspnetForm.<%=TextBox2.clientID%>;
>
What I am trying to do is get the csvdata into my temp table. I tried
to do it in the following function (VB on back) and it works if I can
get the data:
Private Sub fnBeforePaste(ByVal txtPassed As String)
Dim i As Int32
Dim Idata() As String = Split(txtPassed, Chr(13) & Chr(10))
'or use Environment.Newline
If InStr(txtPassed, Environment.NewLine) Then
MsgBox("Environment.Newline")
For i = 0 To Idata.GetUpperBound(0) - 1
Dim stCells() As String = Split(Idata(i), Chr(9)) 'or
use ',' for csvdata
stCells(0) = Replace(stCells(0), Chr(10), "")
If Len(stCells(0)) < 2 Then GoTo ExitPasteGrid
AccessDataSource2.InsertCommand = "INSERT INTO Temptbl
(ESN,[MIN]) SELECT '" & stCells(0) & "' AS Expr1, '" & stCells(1) & "'
AS Expr2;"
'"INSERT INTO Temptbl ( ESN, [MIN] ) SELECT " & stCells(0)
& "," & stCells(1)
AccessDataSource2.Insert()
Next
ExitPasteGrid:
'TextBox2.Text = ""
GridEntry.DataBind()
End Sub
This way I can run a query in the database, and return the query
results in a second grid on the page. I have to use something easy for
users to enter two columns of unknown rows of numerical text values in
a temp table in order to join it to the other query table.
Any suggestions on how to approach this problem are much appreciated.
:)
Try something like this:

Private Sub Save(ByVal CSV As String)

Dim oStream As New System.IO.StringReader(CSV)
Dim oFields As String() = {}

Using oParser As New TextFieldParser(oStream)

oParser.SetDelimiters(",")

While Not oParser.EndOfData

Try
oFields = oParser.ReadFields()

Try
'Validate Field Contents
Catch Ex As Exception

End Try

Catch ex As Exception

End Try

End While

End Using
End Function
Dec 7 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.