I'm trying to use a typed dataset and ObjectDataSource binding to SQLX db using a foreign key to filter the returned result set to display in a GridView.
The error is generated when I try to bind the following GridView to the ObjectSource that follows:
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="Delete" InsertMethod="Insert" SelectMethod="FillMenusByLocation" TypeName="RestaurantsTableAdapters.MenusTableAdapter" UpdateMethod="Update"> <DeleteParameters> <asp:Parameter Name="Original_MenuId" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="LocationId" Type="Int32" /> <asp:Parameter Name="MenuName" Type="String" /> <asp:Parameter Name="IsAvailable" Type="Boolean" /> <asp:Parameter Name="DisplayOrder" Type="Int32" /> <asp:Parameter Name="Original_MenuId" Type="Int32" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="LocationId" Type="Int32" /> <asp:Parameter Name="MenuName" Type="String" /> <asp:Parameter Name="IsAvailable" Type="Boolean" /> <asp:Parameter Name="DisplayOrder" Type="Int32" /> </InsertParameters> </asp:ObjectDataSource>
---------------------------------------------------
<asp:GridView ID="MenusGridView" Runat="server" DataSourceID="ObjectDataSource1" DataKeyNames="LocationId" ShowHeader=True AutoGenerateColumns="False"
CellPadding="4" ForeColor="#333333" GridLines="Both" > <Columns> <asp:BoundField ReadOnly="True" HeaderText="MenuId" DataField="MenuId" SortExpression="MenuId" Visible=True /> <asp:BoundField ReadOnly="True" HeaderText="LocationId" DataField="LocationId" SortExpression="LocationId" Visible=True /> <asp:BoundField HeaderText="Name" DataField="MenuName" SortExpression="MenuName" /> <asp:CheckBoxField HeaderText="Available?" DataField="IsAvailable" SortExpression="IsAvailable" ItemStyle-HorizontalAlign="Center" /> <asp:BoundField HeaderText="DisplayOrder" DataField="DisplayOrder" SortExpression="DisplayOrder" /> </Columns> </asp:GridView>
---------
Here is the XSD for the related TableAdapter<TableAdapter BaseClass="System.ComponentModel.Component" DataAccessorName="MenusTableAdapter" Modifier="AutoLayout, AnsiClass, Class, Public" Name="Menus" WebServiceAttribute="False">
<MainSource>
<DbSource ConnectionRef="ASPNETDBConnectionString (Web.config)" DbObjectName="dbo.Menus" DbObjectType="Table" EnableWebMethods="False" FillMethodModifier="Public" FillMethodName="Fill" GenerateMethods="Both" GeneratePagingMethods="False" GenerateShortCommands="True" GetMethodName="GetData" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="False">
<DeleteCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>DELETE FROM [dbo].[Menus] WHERE (([MenuId] = @Original_MenuId))</CommandText>
<Parameters>
<Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_MenuId" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="MenuId" SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
</Parameters>
</DbCommand>
</DeleteCommand>
<InsertCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>INSERT INTO [dbo].[Menus] ([LocationId], [MenuName], [IsAvailable], [DisplayOrder]) VALUES (@LocationId, @MenuName, @IsAvailable, @DisplayOrder)</CommandText>
<Parameters>
<Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@LocationId" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="LocationId" SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="String" Direction="Input" ParameterName="@MenuName" Precision="0" ProviderType="NVarChar" Scale="0" Size="0" SourceColumn="MenuName" SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="Boolean" Direction="Input" ParameterName="@IsAvailable" Precision="0" ProviderType="Bit" Scale="0" Size="0" SourceColumn="IsAvailable" SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@DisplayOrder" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="DisplayOrder" SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</InsertCommand>
<SelectCommand>
<DbCommand CommandType="Text" ModifiedByUser="True">
<CommandText>SELECT MenuId, LocationId, MenuName, IsAvailable, DisplayOrder FROM Menus</CommandText>
<Parameters>
</Parameters>
</DbCommand>
</SelectCommand>
<UpdateCommand>
<DbCommand CommandType="Text" ModifiedByUser="False">
<CommandText>UPDATE [dbo].[Menus] SET [LocationId] = @LocationId, [MenuName] = @MenuName, [IsAvailable] = @IsAvailable, [DisplayOrder] = @DisplayOrder WHERE (([MenuId] = @Original_MenuId))</CommandText>
<Parameters>
<Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@LocationId" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="LocationId" SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="String" Direction="Input" ParameterName="@MenuName" Precision="0" ProviderType="NVarChar" Scale="0" Size="0" SourceColumn="MenuName" SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="Boolean" Direction="Input" ParameterName="@IsAvailable" Precision="0" ProviderType="Bit" Scale="0" Size="0" SourceColumn="IsAvailable" SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@DisplayOrder" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="DisplayOrder" SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_MenuId" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="MenuId" SourceColumnNullMapping="False" SourceVersion="Original">
</Parameter>
</Parameters>
</DbCommand>
</UpdateCommand>
</DbSource>
</MainSource>
<Mappings>
<Mapping SourceColumn="MenuId" DataSetColumn="MenuId" />
<Mapping SourceColumn="LocationId" DataSetColumn="LocationId" />
<Mapping SourceColumn="MenuName" DataSetColumn="MenuName" />
<Mapping SourceColumn="IsAvailable" DataSetColumn="IsAvailable" />
<Mapping SourceColumn="DisplayOrder" DataSetColumn="DisplayOrder" />
</Mappings>
<Sources>
<DbSource ConnectionRef="ASPNETDBConnectionString (Web.config)" DbObjectName="dbo.Menus" DbObjectType="Table" EnableWebMethods="False" FillMethodModifier="Public" FillMethodName="FillMenusByLocation" GenerateMethods="Both" GeneratePagingMethods="False" GenerateShortCommands="True" GetMethodName="GetMenusByLocation" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="True">
<SelectCommand>
<DbCommand CommandType="Text" ModifiedByUser="True">
<CommandText>SELECT MenuId, MenuName, IsAvailable, DisplayOrder
FROM Menus
WHERE (LocationId = @parameter1)</CommandText>
<Parameters>
<Parameter AllowDbNull="False" AutogeneratedName="parameter1" ColumnName="LocationId" DataSourceName="[C:\SHARE\xyzzy\xyzzy\APP_DATA\ASPNETDB.MDF].dbo.Menus" DataTypeServer="int" DbType="Int32" Direction="Input" ParameterName="@parameter1" Precision="0" ProviderType="Int" Scale="0" Size="4" SourceColumn="LocationId" SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</SelectCommand>
</DbSource>
</Sources>
</TableAdapter>
![]() |
0 |
![]() |