First, instead of doing all of those
Response.Write
calls, use a
StringBuilder
to build the entire output, and to set the text boxes, simply use the
StringBuilder.AppendFormat()
method, like so:
Dim html As New StringBuilder("")
html.Append("<form name=\"forml\" action=\"die1.aspx\" method=\"get\" id=\"form1\">")
html.Append("<table>")
While (dr.Read())
html.Append("<tr>")
html.AppendFormat("<td>{0}</td><td>{1}", dr("XGENAME").ToString(), dr("EANAME").ToString())
html.AppendFormat("<table><tbody><tr><td><input type=\"textbox\" id=\"fone\" text=\"{0}\" /></td></tr></tbody></table>", dr("FONE").ToString())
html.AppendFormat("<table><tbody><tr><td><input type=\"textbox\" id=\"fadd\" text=\"{0}\" /></td></tr></tbody></table>", dr("FADD").ToString())
html.AppendFormat("<table><tbody><tr><td><input type=\"textbox\" id=\"flast\" text=\"{0}\" /></td></tr></tbody></table>", dr("FLAST").ToString())
html.AppendFormat("<table><tbody><tr><td><input type=\"textbox\" id=\"dexp\" text=\"{0}\" /></td></tr></tbody></table>", dr("DEXP").ToString())
html.Append("</td></tr>")
End While
orc.Dispose()
html.Append("</table>")
html.Append("<input type=\"submit\" value=\"submit\">")
html.Append("</input></form>")
Response.Write(html)
That code is much cleaner and easier to maintain (not to mention much shorter).