By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,854 Members | 1,871 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,854 IT Pros & Developers. It's quick & easy.

Please Help with the combox DisplayValue property

P: n/a
raj
Please Help with the combox DisplayValue property

private void cboClient_SelectionChangeCommitted(object sender,
System.EventArgs e)
{
String strSQL;
strSQL = "SELECT F.FollowUpPerson FROM tblFollowUpPerson F INNER JOIN
tblFollowUpPersonClient C ON F.FollowUpPersonID = C.FollowUpPersonID WHERE
C.ClientKey = '" + this.cboClient.SelectedValue + "' ";
ds = mg.GetDataSet(strSQL,"userList"); //Def is described at the end

cmbUserList.DataSource = ds;
cmbUserList.DisplayMember = "FollowUpPerson";
cmbUserList.ValueMember = "FollowUpPerson";

}

//Def
public DataSet GetDataSet(string sqlQuery, string name)
{
SqlConnection conn = null;

if ( m_connInfo == null )
return null;

try
{
if ( persistTrans == null )
conn = new SqlConnection(m_connInfo.DBConnString);
else
conn = persistTrans.Connection;

m_dataAdapter = new SqlDataAdapter(sqlQuery, conn);
SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(m_dataAdapter);
DataSet dataSet = new DataSet(name);
m_dataAdapter.SelectCommand.CommandTimeout = m_connInfo.CommandTimeout;
m_dataAdapter.Fill(dataSet);

return dataSet;
}
catch(Exception e)
{
logger.Write(sqlQuery);
logger.WriteLine(e);
return null;
}
finally
{
if ( persistTrans == null && conn != null )
conn.Close();
}
}

------------------------------------------------------------------------------------------
My application get crashes in
cmbUserList.DisplayMember = "FollowUpPerson";

Could u pls telll me why?

THe error message is
"An unhandled exception of type 'System.ArgumentException' occurred in
system.windows.forms.dll
Additional information: Could not bind to the new display member."

Thanks

raj

Jul 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.