Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
835
WebDropDown Items
posted

Hi there,

How do I add an item when I'm already on Form.aspx.cs? 

cboOriginalBrand.Items.Add("*");  doesn't work anymore.

  • 29417
    Offline posted

     Hello Andrea ,

     

    Thank you for posting in our forum.

    Do you mean when the page is already loaded in the browser?

    If so you can add it on the client  side using java script:

    http://www.infragistics.com/community/forums/p/78574/398781.aspx#398781

     

    Let me know if you perhaps meant something different.

     

     

    Best Regards,

    Maya Kirova

    Developer Support Engineer II

    Infragistics, Inc.

    http://www.infragistics.com/support

     

    • 835
      posted in reply to Maya Kirova
      Hi Maya, I meant when I'm going to add items or calling the items on Form.aspx.cs
      • 29417
        Offline posted in reply to Andrea Minoza

        Hello Andrea ,

         

        Thank you or the clarification.

        The WebDropDown’s Items Add() method accepts objects of type DropDownItem. So you would need to create a new DropDownItem with some text and add it to the Items collection. For example:

        WebDropDown1.Items.Add(new DropDownItem() { Text = "Some Text" });

         

        Let me know if you have any questions.

         

        Best Regards,

        Maya Kirova

        Developer Support Engineer II

        Infragistics, Inc.

        http://www.infragistics.com/support

         

        • 835
          posted in reply to Maya Kirova

          Hi Maya,

          This is the code I currently have:

          protected void setCombo()
          {
          string strConn = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["ORIGSAMPLE"].ToString();

          SqlConnection cn = new SqlConnection(strConn);

          try
          {
          cn.Open();

          string strSQL = "SELECT * FROM [qry_Original_Brands] ORDER BY 1";

          SqlCommand cmd = new SqlCommand(strSQL, cn);
          SqlDataReader dr = cmd.ExecuteReader();

          cboOriginalBrand.Items.Add("*");

          if (dr.HasRows)
          {
          while (dr.Read())
          {
          cboOriginalBrand.Items.Add(dr[0].ToString());

          }
          }

          I'm having a problem with cboOriginalBrand.Items.Add("*"); and cboOriginalBrand.Items.Add(dr[0].ToString());

          Please help me in this.

          • 29417
            Offline posted in reply to Andrea Minoza

            Hello Andrea , 

            Make sure you have added the  following reference: 

            using Infragistics.Web.UI.ListControls; 

            Since the DropDownItem class is defined in that namespace. 

            I’ve attached an example for your reference. Let me know if you have any questions. 

            Best Regards,

            Maya Kirova

            Developer Support Engineer II

            Infragistics, Inc.

            http://www.infragistics.com/support

             

            WebSite1.zip
            • 835
              posted in reply to Maya Kirova

              Hi Maya,

              Adding using Infragistics.Web.UI.ListControls solved it! :D However, how do I fix the other one? cboProductGroup.Items.Add(dr[0].ToString());