EDN Admin
Well-known member
<p style="line-height:normal; margin-bottom:0pt I have a maddening problem (ASP.NET). It seems like really simple code, but it’s not working as expected, and I can’t figure out why!
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt I get data from a database and loop thru it.<span>
I need to dynamically create a server-side table with several controls for each row (checkbox, radiobutton dropdown list, hidden textbox and a submit button). The hidden textbox contains some key data for the row that I need on the postback. The label
(lblTEST) is there for debugging to display the contents of the hidden textbox.
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt Here’s snippet of the code:
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt Dim rw As new TableRow<br/>
Dim cl As new TableCell<br/>
…
<p style="line-height:normal; margin-bottom:0pt …<br/>
<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt cl =
<span style="background:white; color:blue; font-family:Lucida Console; font-size:9.5pt New<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt
<span style="background:white; color:#2b91af; font-family:Lucida Console; font-size:9.5pt TableCell<br/>
<span style="background:white; color:blue; font-family:Lucida Console; font-size:9.5pt Dim<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt txtHidden
<span style="background:white; color:blue; font-family:Lucida Console; font-size:9.5pt As<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt
<span style="background:white; color:blue; font-family:Lucida Console; font-size:9.5pt New<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt
<span style="background:white; color:#2b91af; font-family:Lucida Console; font-size:9.5pt HiddenField<br/>
<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt txtHidden.ID =
<span style="background:white; color:#a31515; font-family:Lucida Console; font-size:9.5pt "txtHidden"<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt & iRowCount.ToString<br/>
<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt txtHidden.Value = Val1 &
<span style="background:white; color:#a31515; font-family:Lucida Console; font-size:9.5pt "|" <span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt & Val2 &
<span style="background:white; color:#a31515; font-family:Lucida Console; font-size:9.5pt "|" <span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt & Val3 &
<span style="background:white; color:#a31515; font-family:Lucida Console; font-size:9.5pt "|" <span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt & Val4<br/>
<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt lblTEST.Text &= txtHidden.Value <span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt
& <span style="background:white; color:#a31515; font-family:Lucida Console; font-size:9.5pt "<br>"<span>
for debugging<br/>
<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt txtHidden.EnableViewState =
<span style="background:white; color:blue; font-family:Lucida Console; font-size:9.5pt False<br/>
<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt cl.Controls.Add(txtHidden)<br/>
<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt rw.Cells.Add(cl)<br/>
<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt tblMyTable.Rows.Add(rw)<br/>
<br/>
<br/>
<p style="line-height:normal; margin-bottom:0pt <span style="color:black; font-family:Lucida Console; font-size:9.5pt The first time the page loads, the 1st row of data contains:<br/>
<span style="color:black; font-family:Lucida Console; font-size:9.5pt lblTEST displays: <span style="color:black; font-family:Lucida Console; font-size:9.5pt <span>
<span style="font-family:Verdana,sans-serif; font-size:10pt 6763|13|0|0
<span> (this is correct)<br/>
<span style="font-family:Verdana,sans-serif; font-size:10pt txtHidden contains: <span style="font-family:Verdana,sans-serif; font-size:10pt
<span> 6763|13|0|0 <span> (this is correct)<br/>
<br/>
<span style="font-family:Verdana,sans-serif; font-size:10pt <br/>
However when the button is clicked and the postback occurs, I get the following:<br/>
<span style="font-family:Verdana,sans-serif; font-size:10pt lblTEST displays: <span style="font-family:Verdana,sans-serif; font-size:10pt
<span> <span>
6763|13|261589215|1562 (this is correct)<br/>
<span style="font-family:Verdana,sans-serif; font-size:10pt txtHidden contains:
<span> <span>
<span style="font-family:Verdana,sans-serif; font-size:10pt 6763|13|0|0
<span>
(this is NOT correct!)<br/>
<br/>
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Verdana,sans-serif; font-size:10pt WHY am I losing the data in the hidden text box?? It seems to be reverting back to the previous value. (it should be noted that all of the other
hidden text boxes have different values).
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Verdana,sans-serif; font-size:10pt Is there something really stupid that I’m doing that I can’t see??
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Verdana,sans-serif; font-size:10pt Thanks,
<
Bert Sirkin
<br/>
<br/>
<br/>
<br/>
View the full article
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt I get data from a database and loop thru it.<span>
I need to dynamically create a server-side table with several controls for each row (checkbox, radiobutton dropdown list, hidden textbox and a submit button). The hidden textbox contains some key data for the row that I need on the postback. The label
(lblTEST) is there for debugging to display the contents of the hidden textbox.
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt Here’s snippet of the code:
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt Dim rw As new TableRow<br/>
Dim cl As new TableCell<br/>
…
<p style="line-height:normal; margin-bottom:0pt …<br/>
<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt cl =
<span style="background:white; color:blue; font-family:Lucida Console; font-size:9.5pt New<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt
<span style="background:white; color:#2b91af; font-family:Lucida Console; font-size:9.5pt TableCell<br/>
<span style="background:white; color:blue; font-family:Lucida Console; font-size:9.5pt Dim<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt txtHidden
<span style="background:white; color:blue; font-family:Lucida Console; font-size:9.5pt As<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt
<span style="background:white; color:blue; font-family:Lucida Console; font-size:9.5pt New<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt
<span style="background:white; color:#2b91af; font-family:Lucida Console; font-size:9.5pt HiddenField<br/>
<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt txtHidden.ID =
<span style="background:white; color:#a31515; font-family:Lucida Console; font-size:9.5pt "txtHidden"<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt & iRowCount.ToString<br/>
<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt txtHidden.Value = Val1 &
<span style="background:white; color:#a31515; font-family:Lucida Console; font-size:9.5pt "|" <span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt & Val2 &
<span style="background:white; color:#a31515; font-family:Lucida Console; font-size:9.5pt "|" <span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt & Val3 &
<span style="background:white; color:#a31515; font-family:Lucida Console; font-size:9.5pt "|" <span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt & Val4<br/>
<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt lblTEST.Text &= txtHidden.Value <span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt
& <span style="background:white; color:#a31515; font-family:Lucida Console; font-size:9.5pt "<br>"<span>
for debugging<br/>
<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt txtHidden.EnableViewState =
<span style="background:white; color:blue; font-family:Lucida Console; font-size:9.5pt False<br/>
<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt cl.Controls.Add(txtHidden)<br/>
<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt rw.Cells.Add(cl)<br/>
<span style="background:white; color:black; font-family:Lucida Console; font-size:9.5pt tblMyTable.Rows.Add(rw)<br/>
<br/>
<br/>
<p style="line-height:normal; margin-bottom:0pt <span style="color:black; font-family:Lucida Console; font-size:9.5pt The first time the page loads, the 1st row of data contains:<br/>
<span style="color:black; font-family:Lucida Console; font-size:9.5pt lblTEST displays: <span style="color:black; font-family:Lucida Console; font-size:9.5pt <span>
<span style="font-family:Verdana,sans-serif; font-size:10pt 6763|13|0|0
<span> (this is correct)<br/>
<span style="font-family:Verdana,sans-serif; font-size:10pt txtHidden contains: <span style="font-family:Verdana,sans-serif; font-size:10pt
<span> 6763|13|0|0 <span> (this is correct)<br/>
<br/>
<span style="font-family:Verdana,sans-serif; font-size:10pt <br/>
However when the button is clicked and the postback occurs, I get the following:<br/>
<span style="font-family:Verdana,sans-serif; font-size:10pt lblTEST displays: <span style="font-family:Verdana,sans-serif; font-size:10pt
<span> <span>
6763|13|261589215|1562 (this is correct)<br/>
<span style="font-family:Verdana,sans-serif; font-size:10pt txtHidden contains:
<span> <span>
<span style="font-family:Verdana,sans-serif; font-size:10pt 6763|13|0|0
<span>
(this is NOT correct!)<br/>
<br/>
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Verdana,sans-serif; font-size:10pt WHY am I losing the data in the hidden text box?? It seems to be reverting back to the previous value. (it should be noted that all of the other
hidden text boxes have different values).
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Verdana,sans-serif; font-size:10pt Is there something really stupid that I’m doing that I can’t see??
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Verdana,sans-serif; font-size:10pt Thanks,
<
Bert Sirkin
<br/>
<br/>
<br/>
<br/>
View the full article