After I load my combobox, it displays System.Data.DataRowView instead of data. I am using the correct column names as returned from the stored procedure (TimeframeDesc and TimeframeCode).
I get the message 'Cannot bind to the new display member' when debugging.
private bool loadTimeframeList(out string msg)
{
msg = "";
string spName = "schemaExec.SelTimeframeCode";
bool result = true;
SqlCommand cmd = new SqlCommand(spName);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = _sqlConn;
try
{
SqlDataAdapter rdr = new SqlDataAdapter(cmd);
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
rdr.Fill(dt);
cbTimeframe.DisplayMember = "TimeframeDesc";
cbTimeframe.ValueMember = "TimeframeCode";
cbTimeframe.DataSource = dt;
}
catch (Exception ex)
{
result = false;
msg = "Could not load Timeframe Codes" + Environment.NewLine + ex.Message;
}
return result;
}
Aucun commentaire:
Enregistrer un commentaire