Click here to Skip to main content
15,900,511 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in my databases all are controls comes in sql db.

VB
If ds1.Tables(0).Rows(i)(0).ToString().Substring(0, 3) = "txt" Then

                       Dim lbl1 As New Label()
                       lbl1.ID = "lbl1" + i.ToString()
                       lbl1.Text = ds1.Tables(0).Rows(i)(1).ToString()
                       lbl1.Text = lbl1.Text + ":" + "       "
                       myDiv.Controls.Add(lbl1)

                       Dim MyTextBox As New TextBox()
                       MyTextBox.ID = ds1.Tables(0).Rows(i)(0).ToString()
                       myDiv.Controls.Add(MyTextBox)

                       'table = table & "<tr><td>" + ds1.Tables(0).Rows(i)(1).ToString() + "</td><td>" + MyTextBox.ID + "</td><td>"
                       myDiv.Controls.Add(New LiteralControl("<br />"))
                       'table = table + "</table>"
                       'myDiv.InnerHtml = table
                       div1.Attributes.Add("class", "button")
                   End If

                   If ds1.Tables(0).Rows(i)(0).ToString().Substring(0, 3) = "cbo" Then

                       Dim lbl2 As New Label()
                       lbl2.ID = "lbl2" + i.ToString()
                       lbl2.Text = ds1.Tables(0).Rows(i)(1).ToString()
                       lbl2.Text = lbl2.Text + ":" + "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"
                       myDiv.Controls.Add(lbl2)


                       Dim ddl As New DropDownList()

                       ddl.AutoPostBack = True
                       'ddl.Height = "27px"
                       'ddl.Width = "130px"
                       ddl.ID = ds1.Tables(0).Rows(i)(0).ToString()
                       ddl.DataSource = ds1.Tables(0).Rows(i)(0).ToString()
                       ddl.DataBind()

                       myDiv.Controls.Add(ddl)
                       myDiv.Controls.Add(New LiteralControl("<br />"))

                       div1.Attributes.Add("class", "button")

                   End If



Dim txtUserName As TextBox = DirectCast(pnlInfo.FindControl(
VB
ds1.Tables(0).Rows(i)(0).ToString()), TextBox)

how to insert all dynamicall values into db.

i'm trying like this but problem is not resolved.

can u send me related examples.....
Posted

1 solution

First u have to define proper table for dynamic insertion of value from textbox. If u want to get proper table structure then u can refer DotNetNuke(DNN) dynamic form generation concept. In DNN they created layered table for same.
 
Share this answer
 
Comments
kumar2233 29-Oct-12 2:47am    
fldtype fldDesc fldname fldparam fldid

1 First Applicant txtFirstApp @txtFirstApp 1
1 Second Applicant txtSecondApp @txtSecondApp 2
1 Third Applicant txtThirdApp @txtThirdApp 3
1 PAN No txtPAN @txtPAN 4
1 J.H1 Pan No. txtJh1Pan @txtJh1Pan 5
2 Bank Name cboBankName @cboBankName 23
2 Bank A/c Type cboBankAcType @cboBankAcType 24
1 Bank A/c No txtBankAccNo @txtBankAccNo 25
1 Bank Add1 txtBankAdd1 @txtBankAdd1 26
1 Bank PIN txtBankPin @txtBankPin 30
1 Bank State txtBankState @txtBankState 31
2 Mode of Red. cboModeofRedemption @cboMode 32
1 IFSC Code txtIFSC @txtIFSC 33


based on fldtype we are create dynamically textboxes and dropdownlist.

in a dynamic textbox text how to store insert a value into sqldb

Collapse | Copy Code

If ds1.Tables(0).Rows(i)(0).ToString() = "1" Then

Dim lbl1 As New Label()
lbl1.ID = "lbl1" + i.ToString()
lbl1.Text = ds1.Tables(0).Rows(i)(1).ToString()
lbl1.Text = lbl1.Text + ":" + "       "
myDiv.Controls.Add(lbl1)

Dim MyTextBox As New TextBox()
MyTextBox.ID = ds1.Tables(0).Rows(i)(0).ToString()
myDiv.Controls.Add(MyTextBox)

'table = table & "<tr><td>" + ds1.Tables(0).Rows(i)(1).ToString() + "</td><td>" + MyTextBox.ID + "</td><td>"
myDiv.Controls.Add(New LiteralControl("<br />"))
'table = table + "</table>"
'myDiv.InnerHtml = table
div1.Attributes.Add("class", "button")
End If

If ds1.Tables(0).Rows(i)(0).ToString()= "2" Then

Dim lbl2 As New Label()
lbl2.ID = "lbl2" + i.ToString()
lbl2.Text = ds1.Tables(0).Rows(i)(1).ToString()
lbl2.Text = lbl2.Text + ":" + "           "
myDiv.Controls.Add(lbl2)


Dim ddl As New DropDownList()

ddl.AutoPostBack = True
'ddl.Height = "27px"
'ddl.Width = "130px"
ddl.ID = ds1.Tables(0).Rows(i)(0).ToString()
ddl.DataSource = ds1.Tables(0).Rows(i)(0).ToString()
ddl.DataBind()

myDiv.Controls.Add(ddl)
myDiv.Controls.Add(New LiteralControl("<br />"))

div1.Attributes.Add("class", "button")

End If



Dim txtUserName As TextBox = DirectCast(pnlInfo.FindControl(ds1.Tables(0).Rows(i)(0).ToString()), TextBox)

how to add all textboxes text values into db.

plz help me...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900