On Tue, 3 Jan 2006 17:58:28 -0800, "T. Wong"
<tw***@nospammeexcite.com> wrote:
But, I don't want to use an asp Datasource because:
1. it can't be shared between pages
2. it puts sql in my aspx file and that's just wrong
I want use a TableAdapter:Dataset that I have put in my App_code folder from
a class in that same folder. I would then call methods in that class from
aspx pages and do a databind to my GridView, or whatever control, in my aspx
codebehind file. That way I can share datasets in my pages and I have no
crapy sql code in my aspx file.
But I can't find a way to reference the TableAdapter:Dataset from my class.
[snip]
I did this just the other day. look in the code generated when to
created you xsd file (YourDataSet.Designer.cs) and search for
TableAdapter you will find a namespace named
YourDataSetTableAdapters. Add a using statement to your class (using
YourDataSetTableAdapters;) and you will be able to call the table
adapters from your code.
Here's an example of code from a test I did for this:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using TestConsole.N5GEDataSetTableAdapters;
namespace TestConsole
{
class Program
{
static void Main(string[] args)
{
USCitiesTableAdapter ta = new USCitiesTableAdapter();
N5GEDataSet ds = new N5GEDataSet();
ta.Fill(ds.USCities);
DataRow [] cities =
ds.USCities.select("Distinct city = 'arlington'", "City, state
ASC");
}
}
}
Otis Mukinfus
http://www.otismukinfus.com http://www.tomchilders.com