I have an issue with an ASP.Net VB page I am trying to build.
The interface is for a Job Sheet so it has one hard coded box for each of the 3 main categories (Tasks, Materials Used, Outstanding Tasks).
Next to each of the first boxes it has a Add Text Box field. The code for this is in VB.net and is below.
Protected Sub btnDescription(ByVal sender As Object, ByVal e As EventArgs)
ViewState("tblDescriptionRowCounter") = (tblDescriptionRowCounter + 1)
Public Sub AddRows_tblDescriptionRowCounter(ByVal rowstoadd As Integer)
Dim i As Integer = 0
Do While (i < rowstoadd)
Dim row As TableRow = New TableRow
Dim cell1 As TableCell = New TableCell
Dim cell2 As TableCell = New TableCell
Dim intWidth As New Unit(100, UnitType.Percentage)
Dim intFontSize As FontSize = FontSize.XXLarge
Dim txtTextBox As New TextBox()
txtTextBox.BorderStyle = BorderStyle.Solid
txtTextBox.Width = intWidth
txtTextBox.TextMode = TextBoxMode.MultiLine
txtTextBox.Font.Size = txtDescriptionOfJobOrTask_1.Font.Size
txtTextBox.Height = txtDescriptionOfJobOrTask_1.Height
i = (i + 1)
I have attempted to put in a manual ID (and make it unique based on a number) for each TextBox but it always says “ID already on page”.
The issue I am getting is when someone enters data in this order (For example).
Enter Data in Description of Task
Press Add Row (ON Description)
Enter Data in Materials Used
Press Add Row (On Materials)
Enter Data in new box on the Description Tasks
Enter Data in new box on the Materials.
Press Add Row (on either Materials or Tasks).
It then puts the data in the wrong text boxes.
It should be like this
However when the user does enter data for that section and presses Add Row. Then once a blank box has appeared underneath, the user moves onto the next section and presses Add Row. All the data is being returned in the correct boxes.
I believe it has something to do about the ViewState controls and ID’s of the controls during a postback (not the best web developer but doing some research appears to point to this).
Any idea on how I can correct this error please?