-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: PKandoth
Message 1 in Discussion
Hi I've the following code to fill items to a combo box.
private struct ComboItem
{
private string strDisplay;
private int intValue;
public ComboItem(string DisplayItem,int ValueItem)
{
strDisplay=DisplayItem;
intValue=ValueItem;
}
public string DisplayName
{
get
{
return strDisplay;
}
}
public int ValueItem
{
get
{
return intValue;
}
}
}
string strQuery;
ArrayList HldValue = new ArrayList();
//ArrayList arlLoc = new ArrayList() ;
SqlCommand scmdFill;
SqlDataReader sdrFill;
strQuery = string.Concat("select " ,Field ,",",Value," from " , TableName, "
where " , Cond);
conLog.Open();
scmdFill = new SqlCommand(strQuery,conLog);
sdrFill = scmdFill.ExecuteReader();
Combo.Items.Clear();
while(sdrFill.Read())
{
HldValue.Add (new ComboItem(sdrFill.GetString(0),sdrFill.GetInt32(1)));
}
if( HldValue.Count >0)
{
Combo.DataSource = HldValue;
Combo.DisplayMember = "DisplayName";
Combo.ValueMember = "ValueItem";
}
sdrFill.Close();
conLog.Close();
if( Combo.Items.Count > 0)
Combo.SelectedIndex = 0;
This code works fine in VS 2002 but when i run this code in VS 2003
"Combo.Items.Count" always return zero inspite of the data reader returning
around 15 items. Somebody please help
Regards
Pradeep
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you
received this message by mistake, please click the "Remove" link below. On the
pre-addressed e-mail message that opens, simply click "Send". Your e-mail
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]