listbox problems

jackson

New Member
Here is the code I have. I am trying to do this because when ever I add a list item using the add method I can't add an item that has different text and value. So I tried to do this:<BR><BR><asp:ListBox SelectionMode="Single" Rows="1" ID="PayFrequency" Runat="server"><BR><%<BR>if (strFreq1 != "")<BR>{<BR>%><BR><asp:ListItem Value=http://aspmessageboard.com/archive/index.php/"<%Response.Write(strFreq1val)%>"><%Response.Write(strFreq1) %></asp:ListItem><BR><%<BR>}<BR>%><BR></asp:ListBox><BR><BR>But I get this error: Code blocks are not supported in this context<BR><BR>So could someone help me and show me the best way to add a listitem to a listbox and still be able to have a different value field from the text part of the list item.<BR><BR>ThanksYou are merging old asp with asp.net improperly.<BR><BR>You can not do this:<BR><BR><%Response.Write(strFreq1val)%><BR><BR>within a ServerControl tag. <BR><BR>This is pretty fundemental stuff, I would suggest checking out the Tutorials at http://www.asp.net/ or those available with visualstudio.net. It is well worth the time and effort.<BR><BR>btw ...<BR>"<%Response.Write(strFreq1val)%>" is a code block.
 
Back
Top