Hi there,
How do I add an item when I'm already on Form.aspx.cs?
cboOriginalBrand.Items.Add("*"); doesn't work anymore.
what about if it's just cboBuyer.Text = "*"; ?
Hello Andrea ,
As I said the Add() method does not accept string.
It accepts a DropDownItem object.
So you need to create a new DropDownItem and set it’s Text. The Text will be the string that will be displayed in the item.
For example:
cboProductGroup.Items.Add(new DropDownItem() { Text = dr[0].ToString()});
Let me know if you have any further questions.
Best Regards,
Maya Kirova
Developer Support Engineer II
Infragistics, Inc.
http://ko.infragistics.com/support
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());
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.
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.