Velocity Reviews

Velocity Reviews (
-   ASP .Net (
-   -   V2003: Multi-Table Dataset in DataGrid (

bh 10-30-2006 07:52 PM

V2003: Multi-Table Dataset in DataGrid
Using the pubs database, for testing, and example, I'm trying to bind a
datagrid that draws data from multiple tables to use for updating multiple
rows at once. For my example, I want to display Titles, Authors & Prices,
and update the prices. The code I'm using is below, but I get an exception,
on binding the grid stating "A field or property with the name 'Pub_name'
was not found on the selected datasource". In the command window, in Debug
mode, I've verified that the data is in the dataset for both tables.
Pub_name is on the parent table, so how would I reference that on the
datagrid? Thanks in advance.


Dim daPub As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM
Publishers", conn)
Dim daTitles As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM
Titles", conn)

Dim ds As New DataSet
daPub.Fill(ds, "Publishers")
daTitles.Fill(ds, "Titles")

Dim data_relation As New _
DataRelation("TitlePublishers", _
ds.Tables("Publishers").Columns("Pub_Id"), _

DataGrid1.DataSource = ds
DataGrid1.DataKeyField = "Title_id"
DataGrid1.DataMember = "Titles"


The DataGrid's columns are as follows:
<asp:BoundColumn DataField="Title_ID" />
<asp:BoundColumn DataField="Title" HeaderText="Title" />
<asp:BoundColumn DataField="Pub_id" />
<asp:BoundColumn DataField="Pub_name" HeaderText="Publisher" />
<asp:TemplateColumn HeaderText="Price">
<asp:TextBox id="txtPrice" runat="server" MaxLength="6"
Columns="6" Text='<%# DataBinder.Eval(Container, "DataItem.Price") %>' />

All times are GMT. The time now is 05:06 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.