Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String Builder in vb code behind

Status
Not open for further replies.

need2progm

Programmer
Dec 13, 2002
92
US
Is it possible to get the value of a control that has been dynamically built with a string builder from an aspx page?


This is what I have so far :

For Each a In Accounts

Dim newfile As New AccountFile( a.AccountID , 1 , User )

Dim Row As New System.Web.UI.HtmlControls.HtmlTableRow()
Dim cellA As New System.Web.UI.HtmlControls.HtmlTableCell()
Dim cellB As New System.Web.UI.HtmlControls.HtmlTableCell()

cellA.InnerHtml = newFile.AccountText

'build and add DropDown
Dim sbSelectAccount As New StringBuilder()
sbSelectAccount.Append(&quot;<SELECT id= 'userAccount' runat='server'>&quot;)

For Each name In collectionNames

Dim new Name As New NameAccount( name.nameID , 1 , Session(&quot;User&quot;))

sbSelectAccount.Append(&quot;<OPTION value= &quot; NameAccount.NameID & &quot; >&quot;)
sbSelectAccount.Append(&quot; &quot; & NameAccount.AccountText & &quot; &quot;)
sbSelectAnswer.Append(&quot;</OPTION>&quot;)

Next

sbSelectAnswer.Append(&quot;</SELECT>&quot;)

cellB.InnerHtml = sbSelectAnswer.ToString
Row.Cells.Add(cellA)
Row.Cells.Add(cellB)

Next

This returns a drop down box that is populated with (8+items) that are selectable. What I need to know is how do to get the selected item value (text) or ID on post back using vb code behind?.. willing to rewrite in c# if need be.

Thanks for any ideas on how to approach this.
 
When you build a control in that manner, the only way is the old way of doing things:

dim userAccountValue as string = request.form(&quot;userAccount&quot;)
penny1.gif
penny1.gif

The answer to getting answered -- faq855-2992
 

hmmm ok ... don't mind doing it the old way.. but will I have a performance issue due to a post back for every selection when selection is made?

This Table will have 10+ rows with a drop down in each row. Is their away to get around that?

oh .. I guess I could
sbSelectAccount.Append(&quot;<SELECT id= & 'NameAccount.NameID '& >&quot;)


Then could I... do this for ever drop down ?
dim userAccountValue as string = request.form(&quot;NameAccount.NameID&quot;)

 
Why not just use an asp:dropDownList ??
penny1.gif
penny1.gif

The answer to getting answered -- faq855-2992
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top