R
Rathtap
I get the following error on Line 49 (UG1.DataBind()) only if the
Select Stored procedure returns no records. I am using a dataadapter
and a dataset and binding the datagrid to the dataset. If there is
even one record my grid populates perfectly.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.
Source Error:
Line 46opulateDataSet();
Line 47:UG1.DisplayLayout.AllowUpdateDefault=AllowUpdate.Yes;
Line 48:UG1.DataSource=dsetAPC1.Tables[ParentTable].DefaultView;
Line 49:UG1.DataBind();
Line 50:
Line 51:
private void populateDataSet()
{
Cnn.ConnectionString =
ConfigurationSettings.AppSettings["ConnectionString"];
sqlSelectCommand1.Parameters["@payer_id"].Value = payer_id;
daAPC1.SelectCommand=sqlSelectCommand1;
daAPC1.MissingSchemaAction = MissingSchemaAction.AddWithKey;
daAPC1.Fill(dsetAPC1,ParentTable);
UG1.Bands[0].DataKeyField=dsetAPC1.Tables[ParentTable].PrimaryKey[0].ColumnName
+ "," + dsetAPC1.Tables[ParentTable].PrimaryKey[1].ColumnName;
}
Select Stored procedure returns no records. I am using a dataadapter
and a dataset and binding the datagrid to the dataset. If there is
even one record my grid populates perfectly.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.
Source Error:
Line 46opulateDataSet();
Line 47:UG1.DisplayLayout.AllowUpdateDefault=AllowUpdate.Yes;
Line 48:UG1.DataSource=dsetAPC1.Tables[ParentTable].DefaultView;
Line 49:UG1.DataBind();
Line 50:
Line 51:
private void populateDataSet()
{
Cnn.ConnectionString =
ConfigurationSettings.AppSettings["ConnectionString"];
sqlSelectCommand1.Parameters["@payer_id"].Value = payer_id;
daAPC1.SelectCommand=sqlSelectCommand1;
daAPC1.MissingSchemaAction = MissingSchemaAction.AddWithKey;
daAPC1.Fill(dsetAPC1,ParentTable);
UG1.Bands[0].DataKeyField=dsetAPC1.Tables[ParentTable].PrimaryKey[0].ColumnName
+ "," + dsetAPC1.Tables[ParentTable].PrimaryKey[1].ColumnName;
}