Results 1 to 1 of 1
\r\n \r\n\r\n \r\n \r\n
\r\n
\r\n
\r\n Good day,
\r\n
\r\nPlease can someone help me. I am able to create textboxes dynamically and retrieve them again after postback. However I am not able to retrieve the values I enter into these dyncamically created textboxes. Can someone help me?
\r\n
\r\nThis is my code for creating the textboxes and attempting to retrieve the values, but that isn\'t working as they are never saved to the Session Variable I realise, but how can I get them?
\r\n
\r\n Dim tRow As TableRow
\r\n Dim tCell As TableCell
\r\n Dim tTxt As TextBox
\r\n Dim tTxtExist As TextBox
\r\n
\r\n If Session("tbl_Table") Is Nothing Then
\r\n Else
\r\n \'Existing Rows
\r\n For nRows = 2 To Session("tbl_Table").Rows.Count
\r\n tRow = New TableRow
\r\n For nCellExist = 1 To 4
\r\n tCell = New TableCell
\r\n tTxt = New TextBox
\r\n
\r\n tCell.ID = "tblCell" & nRows & nCellExist
\r\n
\r\n tTxt.ID = "txt" & nRows & nCellExist
\r\n tTxt.Width = Unit.Pixel(80)
\r\n tTxtExist = New TextBox
\r\n tTxtExist = Session("tbl_Table").Rows(nRows - 1).Cells(nCellExist - 1).Controls(0)
\r\n tTxt.Text = tTxtExist.Text
\r\n tCell.Controls.Add(tTxt)
\r\n tCell.Width = Unit.Pixel(40)
\r\n tRow.Cells.Add(tCell)
\r\n Next
\r\n tblLTI.Rows.Add(tRow)
\r\n Next
\r\n End If
\r\n
\r\n \'New Rows
\r\n tRow = New TableRow
\r\n For nLoop = 1 To 4
\r\n tCell = New TableCell
\r\n tTxt = New TextBox
\r\n
\r\n tCell.ID = "tblCell" & tbl.Rows.Count & nLoop
\r\n
\r\n tTxt.ID = "txt" & tbl.Rows.Count & nLoop
\r\n tTxt.Width = Unit.Pixel(80)
\r\n tCell.Controls.Add(tTxt)
\r\n tCell.Width = Unit.Pixel(40)
\r\n tRow.Cells.Add(tCell)
\r\n Next
\r\n tblLTI.Rows.Add(tRow)
\r\n
\r\n Session("tbl_Table") = tbl
\r\n
\r\n
\r\n\r\n \r\n\r\n\r\n
\r\n \r\n \r\n \r\n \r\n \r\n
\r\n
\r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n Reply With Quote Reply With Quote \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n\r\n \r\n\r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n
\r\n
\r\n\r\n'; // next/previous post info pn[6647350] = "6647350,6647350"; pn[0] = ",6647350"; // cached usernames pu[0] = guestphrase; pu[95619] = "plsh"; // -->

Threaded View

  1. #1
    Join Date
    Nov 2004
    Posts
    288
    Provided Answers: 1

    Unanswered: Retain value of dynamically created textbox

    Good day,

    Please can someone help me. I am able to create textboxes dynamically and retrieve them again after postback. However I am not able to retrieve the values I enter into these dyncamically created textboxes. Can someone help me?

    This is my code for creating the textboxes and attempting to retrieve the values, but that isn't working as they are never saved to the Session Variable I realise, but how can I get them?

    Dim tRow As TableRow
    Dim tCell As TableCell
    Dim tTxt As TextBox
    Dim tTxtExist As TextBox

    If Session("tbl_Table") Is Nothing Then
    Else
    'Existing Rows
    For nRows = 2 To Session("tbl_Table").Rows.Count
    tRow = New TableRow
    For nCellExist = 1 To 4
    tCell = New TableCell
    tTxt = New TextBox

    tCell.ID = "tblCell" & nRows & nCellExist

    tTxt.ID = "txt" & nRows & nCellExist
    tTxt.Width = Unit.Pixel(80)
    tTxtExist = New TextBox
    tTxtExist = Session("tbl_Table").Rows(nRows - 1).Cells(nCellExist - 1).Controls(0)
    tTxt.Text = tTxtExist.Text
    tCell.Controls.Add(tTxt)
    tCell.Width = Unit.Pixel(40)
    tRow.Cells.Add(tCell)
    Next
    tblLTI.Rows.Add(tRow)
    Next
    End If

    'New Rows
    tRow = New TableRow
    For nLoop = 1 To 4
    tCell = New TableCell
    tTxt = New TextBox

    tCell.ID = "tblCell" & tbl.Rows.Count & nLoop

    tTxt.ID = "txt" & tbl.Rows.Count & nLoop
    tTxt.Width = Unit.Pixel(80)
    tCell.Controls.Add(tTxt)
    tCell.Width = Unit.Pixel(40)
    tRow.Cells.Add(tCell)
    Next
    tblLTI.Rows.Add(tRow)

    Session("tbl_Table") = tbl

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •