C
crjunk
I'm trying to write a piece of code that will programatically save a
record automatically without me having to add a new ' Row.Item("ADD1")
= txtAdd1.Text.Trim.ToUpper ' type command each time I add a new
textbox. I've named all my textboxes in the following format txtAdd1
and I've named all my field in the SQL table the same way minus the
txt at the beginning.
This code scans the form for textboxes. If it finds a text box that
is not disabled, then it is supposed to save the text, typed by the
user, into the SQL table. The only problem is that the text the user
typed in is not being saved to the table, such as "John" in my
FirstName field.
I tried adding a label (Label2) to my form so I could see what might
be going on, but no text is displayed in Label2 after the postback.
Does anyone have any suggestions?
Thanks,
crjunk
Here is what I have so far:
Dim ctrl As Control
Dim ctlNameText As TextBox
Dim ctlNameDDL As DropDownList
For Each ctrl In Me.Controls
If (TypeOf (ctrl) Is TextBox) Then
ctlNameText = ctrl
If ctlNameText.Enabled = True Then
Dim FieldName As String
FieldName = ctrl.ID
Row.Item(Mid(Trim(FieldName), 4, Len(FieldName))) =
ctlNameText.Text.Trim.ToUpper + ""
Label2.Text = Label2.Text.Trim + " " +
ctlNameText.Text.Trim.ToUpper
End If
End If
Next
record automatically without me having to add a new ' Row.Item("ADD1")
= txtAdd1.Text.Trim.ToUpper ' type command each time I add a new
textbox. I've named all my textboxes in the following format txtAdd1
and I've named all my field in the SQL table the same way minus the
txt at the beginning.
This code scans the form for textboxes. If it finds a text box that
is not disabled, then it is supposed to save the text, typed by the
user, into the SQL table. The only problem is that the text the user
typed in is not being saved to the table, such as "John" in my
FirstName field.
I tried adding a label (Label2) to my form so I could see what might
be going on, but no text is displayed in Label2 after the postback.
Does anyone have any suggestions?
Thanks,
crjunk
Here is what I have so far:
Dim ctrl As Control
Dim ctlNameText As TextBox
Dim ctlNameDDL As DropDownList
For Each ctrl In Me.Controls
If (TypeOf (ctrl) Is TextBox) Then
ctlNameText = ctrl
If ctlNameText.Enabled = True Then
Dim FieldName As String
FieldName = ctrl.ID
Row.Item(Mid(Trim(FieldName), 4, Len(FieldName))) =
ctlNameText.Text.Trim.ToUpper + ""
Label2.Text = Label2.Text.Trim + " " +
ctlNameText.Text.Trim.ToUpper
End If
End If
Next