I have a DataGrid on a WebForm. When I select that DataGrid and go to
the "DataSource" property in the properties box, the drop-down lets me
select dataSet11, which is the name of an object instance of class
DataSet1, which VS.Net created for me derived from DataSet.

However, DataSet1 has a schema with two tables in it -- if I
right-click dataSet11 and pick "View Schema" it shows two tables,
wbuser and BennettEmployee.

Now, as soon as I set the DataSource property of my DataGrid to
dataSet11, the layout of the DataGrid on the WebForm changes to
display the columns "myusername", "mynickname", and "ID" -- these are
the columns in the wbuser table from the DataSet1 schema.

So, two questions:

- Does this mean that "wbuser" is somehow the "default" table in the
DataSet1 schema, so that if the DataSource is set to dataSet11, it
automatically maps to the "wbuser" table of that DataSet, as opposed
to the "BennettEmployee" table? Is there a way to change the default
table to "BennettEmployee"?

- More importantly, why does the DataSource dropdown in the IDE only
let me set the DataSource to a *DataSet*, instead of a table within
that DataSet? Since the data in the DataGrid is being pulled from a
table, why won't it let me specify a table?

Am I looking at this in some fundamentally wrong way?

-Bennett

Re: why can I set grid's DataSource to a DataSet but not to a table in the DataSet? by Miha

Miha
Sun Jul 25 02:24:18 CDT 2004

Hi Bennet,

"Bennett Haselton" <bennett@peacefire.org> wrote in message
news:e614455c.0407242003.77e0e317@posting.google.com...
> I have a DataGrid on a WebForm. When I select that DataGrid and go to
> the "DataSource" property in the properties box, the drop-down lets me
> select dataSet11, which is the name of an object instance of class
> DataSet1, which VS.Net created for me derived from DataSet.
>
> However, DataSet1 has a schema with two tables in it -- if I
> right-click dataSet11 and pick "View Schema" it shows two tables,
> wbuser and BennettEmployee.
>
> Now, as soon as I set the DataSource property of my DataGrid to
> dataSet11, the layout of the DataGrid on the WebForm changes to
> display the columns "myusername", "mynickname", and "ID" -- these are
> the columns in the wbuser table from the DataSet1 schema.
>
> So, two questions:
>
> - Does this mean that "wbuser" is somehow the "default" table in the
> DataSet1 schema, so that if the DataSource is set to dataSet11, it
> automatically maps to the "wbuser" table of that DataSet, as opposed
> to the "BennettEmployee" table? Is there a way to change the default
> table to "BennettEmployee"?

The default table in this situation is the first table in collection or
first table created in dataset. You can change it by chagning the dataset
schema (put element containing your default table on the top of
<xs:choice maxOccurs="unbounded">


>
> - More importantly, why does the DataSource dropdown in the IDE only
> let me set the DataSource to a *DataSet*, instead of a table within
> that DataSet? Since the data in the DataGrid is being pulled from a
> table, why won't it let me specify a table?

Use DataMember property for picking the table you want.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com