[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

save values of dynamic controls in sql db

Posted on 2011-02-11
2
Medium Priority
?
231 Views
Last Modified: 2012-05-11
i have created a form dynamically and trying to save the values into my database when user submit the form.

this code is for creating
 
row = New HtmlTableRow()
                    cell = New HtmlTableCell
                    Dim tb1 As New TextBox
                    tb1.ID = "TextBoxID" + (i).ToString
                    tb1.TextMode = TextBoxMode.MultiLine
                    tb1.Width = Unit.Pixel(350)
                    tb1.Height = Unit.Pixel(100)
                    cell.Controls.Add(tb1)
                    row.Controls.Add(cell)
                    newtables.Controls.Add(row)

Open in new window


this code is for saving
 
Dim dorkks = CType(newtables.FindControl("TextBoxID" + t.ToString), TextBox)
                Dim doconnstring As String = System.Configuration.ConfigurationManager.ConnectionStrings("dbconnector").ConnectionString
                Dim doSqlString As String = "INSERT INTO answer (qid, answer) VALUES ('" & cccdatareader.Item("qid") & "', '" & dorkks.ToString & "')"
                Dim doconn As OleDbConnection
                Dim docommand As OleDbCommand
                doconn = New OleDbConnection(doconnstring)
                docommand = New OleDbCommand()
                Dim dodatareader As OleDbDataReader
                doconn.Open()
                docommand.Connection = doconn
                docommand.CommandType = CommandType.Text
                docommand.CommandText = doSqlString
                dodatareader = docommand.ExecuteReader
                dodatareader.Close()
                doconn.Close()
                doconn = Nothing

Open in new window



when it save it doent save user inputed value. its saved as following
System.Web.UI.WebControls.TextBox

0
Comment
Question by:issay
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Accepted Solution

by:
quizwedge earned 2000 total points
ID: 34877238
Try changing line 1 in the saving code from

Dim dorkks = CType(newtables.FindControl("TextBoxID" + t.ToString), TextBox)

To

Dim dorkks as Textbox = CType(newtables.FindControl("TextBoxID" + t.ToString), TextBox)

and line 3 in the saving code from

Dim doSqlString As String = "INSERT INTO answer (qid, answer) VALUES ('" & cccdatareader.Item("qid") & "', '" & dorkks.ToString & "')"

To


Dim doSqlString As String = "INSERT INTO answer (qid, answer) VALUES ('" & cccdatareader.Item("qid") & "', '" & dorkks.Text & "')"
0
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 34878222
looks like the default property is the control name rather than it "value"

dorkks.value.tostring?
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question