locked
Using Items definition on public static void in c# RRS feed

  • Question

  • User1151703306 posted

    Hello there,

    I have problem using Items on public static void.

    When I try to recover with a for each the items element is not recognized.

    How to do resolve this ?

    Please, can you help me ?

    My code below.

      <asp:DropDownCheckBoxes ID="propo" runat="server"
            UseSelectAllNode="false"
            Enabled="true"
            CssClass="body"
            UseButtons="true">
            <Style SelectBoxWidth="400"
                DropDownBoxBoxWidth="400"
                DropDownBoxBoxHeight="500"
                SelectBoxCssClass="body"
                DropDownBoxCssClass="body" />
            <Texts SelectBoxCaption="[ ------- Select ------- ]" />
        </asp:DropDownCheckBoxes>
    
    
    public class pnpropo
    {
        public List<System.Web.UI.WebControls.ListItem> propo { get; set; }
    }
    
    [WebMethod(EnableSession = true)]
    [ScriptMethod]
    public static void Savepnpro(pnpropo pro)
    {
       string xpro = string.Empty;
    
       foreach (System.Web.UI.WebControls.ListItem item in pro.propo) <<< line error
       {
          if (item.Selected)
          {
             xpro += item.Value + "; ";
          }
       }
    }

    Thursday, February 20, 2020 2:18 PM

Answers