Dynamic Values

Discussion in 'ASP.NET 2.0' started by wisemx, Mar 15, 2008.

  1. Hi,
    May I suggest you head over the the http://asp.net site and watch a few of the Learning videos?
    There are a bunch of things wrong with the code you have posted.
    Seems you may have done some classic ASP coding, and it's bad practice in ASP.NET pages.
    You need to build your dynamic values in subs, then place those values where you want them.
    Many of the ASP.NET 2.0 controls will do most of this work for you.
    You can use templates, expressions, literals, etc., to place your values once they're generated.
    By the way, besides using old school methods your ListItem line also has a typo in it. [​IMG]
    Salute,
    Mark
     
  2. Hello,

    I am new to ASP.NET. Please help me solving this problem. I have a column called Date of Membership which has 3 drop down boxes called DD,MM,YYYY. I am trying to fill the DD dynamically instead of writting 31line static code. Getting this error,

    Parser Error
    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

    Parser Error Message: Code blocks are not supported in this context.

    Source Error:






    Code:
    Line 59:                     <asp:DropDownList ID="DropDownList1" runat="server">
    Line 60:                         <asp:ListItem Value="0">DD</asp:ListItem>
    Line 61:                     <% FOR i=1 to 31 %>
    Line 62:                         <asp:ListItem Value="<%=i%>"><%=i%></asp:ListItem>
    Line 63:                     <%next%>
    Source File: /WebSite5/adminreg.aspx Line: 61
    --------------
    Part of the code is this :




    <asp:DropDownList ID="DropDownList1" runat="server">


    <asp:ListItem Value="0">DD</asp:ListItem>


    <% FOR i=1 to 31 %>


    <asp:ListItem Value="<%=i%>"><%=i%></asp:ListItem>


    <%next%>


    </asp:DropDownList>


    Can anyone please tell me how can i print the values dynamically either ways.


    Thanks in Advance
     

Share This Page