Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / May 2008

Tip: Looking for answers? Try searching our database.

Checking the existance of a dataTable in a dataSet

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andy B - 27 May 2008 00:32 GMT
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?
Munna - 27 May 2008 08:06 GMT
> 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
[quoted text clipped - 41 lines]
> How do I fix this to make a valid check against the Header table to see if
> it exists or not?

Hi

try

ds.Tables.Contains("your table name");

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.