M
mark4asp
'System.DBNull' is a 'type', which is not valid in the given context
If dr["OfficeName"] is not an object then what is it? It is certainly
not a string because it hasn't yet been cast as one.
private void PopulateControls()
{
//If this is in AddMode then the table will be empty
if (_dsData.Tables["consultant_office"] != null &&
_dsData.Tables["consultant_office"].Rows.Count == 1)
{
DataRow dr = _dsData.Tables["Consultant_Office"].Rows[0];
txtOfficeName.Text = CheckNull(dr["OfficeName"]);
txtAddress.Text = CheckNull(dr["Address"]);
txtTel.Text = CheckNull(dr["Tel"]);
txtFax.Text = CheckNull(dr["Fax"]);
txtEmail.Text = CheckNull(dr["Email"]);
txtURL.Text = CheckNull(dr["URL"]);
chkDefault.Checked = (bool)dr["Default"];
}
}
private string CheckNull(object dataColumn)
{
if (dataColumn == System.DBNull)
return "";
else
return (string)dataColumn;
}
If dr["OfficeName"] is not an object then what is it? It is certainly
not a string because it hasn't yet been cast as one.
private void PopulateControls()
{
//If this is in AddMode then the table will be empty
if (_dsData.Tables["consultant_office"] != null &&
_dsData.Tables["consultant_office"].Rows.Count == 1)
{
DataRow dr = _dsData.Tables["Consultant_Office"].Rows[0];
txtOfficeName.Text = CheckNull(dr["OfficeName"]);
txtAddress.Text = CheckNull(dr["Address"]);
txtTel.Text = CheckNull(dr["Tel"]);
txtFax.Text = CheckNull(dr["Fax"]);
txtEmail.Text = CheckNull(dr["Email"]);
txtURL.Text = CheckNull(dr["URL"]);
chkDefault.Checked = (bool)dr["Default"];
}
}
private string CheckNull(object dataColumn)
{
if (dataColumn == System.DBNull)
return "";
else
return (string)dataColumn;
}