Hi there,
How do I add an item when I'm already on Form.aspx.cs?
cboOriginalBrand.Items.Add("*"); doesn't work anymore.
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
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.
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.
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.
Adding using Infragistics.Web.UI.ListControls solved it! :D However, how do I fix the other one? cboProductGroup.Items.Add(dr[0].ToString());