A
Andy B
Part of my wizard code requires that when each wizardStep is activated, a
check is done to make sure a certain table in a dataset does exist. If it
does exist, bind to it and show the contents in the gridView. If it doesn't
exist, just bind to the gridView and show the emptyDataTemplate. I have this
code so far:
protected void CreateContractWizard_ActiveStepChanged(object sender,
EventArgs e)
{
//Assign the wizard's ActiveStep title to the wizard HeaderText. That way
each wizard step has a visible title
CreateContractWizard.HeaderText = "Create stock contract - " +
CreateContractWizard.ActiveStep.Title;
//Show the Grid for each step when changing between steps.
if(CreateContractWizard.ActiveStepIndex==0) {
//The Header table has data from WizardStep 0. Check to see if the table
exists and either bind to it or show the emptyDataTemplate if it doesn't
exist.
//I get a compiler error: 'Can not apply the ! operator to type DataTable'
in the next line.
if(!((StockContract)Session["StockContract"]).Contract.Tables["Header"]) {
HeaderDisplayGrid.DataBind();
} else {
HeaderDisplayGrid.DataSource =
((StockContract)Session["StockContract"]).Contract.Tables["Header"];
HeaderDisplayGrid.DataBind();
} //End Header table test
} //end ActiveStepIndex = 0 test
}
How do I fix this to make a valid check against the Header table to see if
it exists or not?
check is done to make sure a certain table in a dataset does exist. If it
does exist, bind to it and show the contents in the gridView. If it doesn't
exist, just bind to the gridView and show the emptyDataTemplate. I have this
code so far:
protected void CreateContractWizard_ActiveStepChanged(object sender,
EventArgs e)
{
//Assign the wizard's ActiveStep title to the wizard HeaderText. That way
each wizard step has a visible title
CreateContractWizard.HeaderText = "Create stock contract - " +
CreateContractWizard.ActiveStep.Title;
//Show the Grid for each step when changing between steps.
if(CreateContractWizard.ActiveStepIndex==0) {
//The Header table has data from WizardStep 0. Check to see if the table
exists and either bind to it or show the emptyDataTemplate if it doesn't
exist.
//I get a compiler error: 'Can not apply the ! operator to type DataTable'
in the next line.
if(!((StockContract)Session["StockContract"]).Contract.Tables["Header"]) {
HeaderDisplayGrid.DataBind();
} else {
HeaderDisplayGrid.DataSource =
((StockContract)Session["StockContract"]).Contract.Tables["Header"];
HeaderDisplayGrid.DataBind();
} //End Header table test
} //end ActiveStepIndex = 0 test
}
How do I fix this to make a valid check against the Header table to see if
it exists or not?