Hi
I get the error Invalid column name 'MakerID' from my code below.
<asp:GridView ID="GridView1" AllowSorting="true" AllowPaging="true" runat="server" DataSourceID="SqlDataSource1"
AutoGenerateDeleteButton="true" AutoGenerateEditButton="true" DataKeyNames="CamID"AutoGenerateColumns="False">
<Columns>
<asp:BoundField Visible="false" ReadOnly="true" HeaderText="ID" DataField="CamID" SortExpression="CamID" />
<asp:BoundField HeaderText="Kamera" DataField="CamName" SortExpression="CamName" />
<asp:BoundField HeaderText="MakerID" DataField="MakerID" SortExpression="MakerID" />
<asp:TemplateField HeaderText="Tillverkare">
<EditItemTemplate>
<asp:SqlDataSource SelectCommand="Select * from Maker" ConnectionString="<%$ ConnectionStrings:CamConnString %>"
ID="SqlDSMaker" runat="server"></asp:SqlDataSource>
<asp:DropDownList ID="ddlMaker" runat="server" AppendDataBoundItems="true" DataSourceID="SqlDSMaker"
DataTextField="MakerName" DataValueField="MakerID" AutoPostBack="True" SelectedValue='<%# Eval("MakerID") %>'>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:SqlDataSource SelectCommand="Select * from Maker" ConnectionString="<%$ ConnectionStrings:CamConnString %>"
ID="SqlDSMaker" runat="server"></asp:SqlDataSource>
<asp:DropDownList ID="ddlMaker1" runat="server" AppendDataBoundItems="true" DataSourceID="SqlDSMaker"
DataTextField="MakerName" DataValueField="MakerID" AutoPostBack="True" SelectedValue='<%# Eval("MakerID") %>'>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Megapixels" DataField="MegaPix" SortExpression="MegaPix" />
<asp:BoundField HeaderText="Pris" DataField="Price" SortExpression="Price" />
<asp:BoundField HeaderText="Antal" DataField="Quantity" SortExpression="Quantity" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" SelectCommand="select CamID, CamName,MakerName,MegaPix,Price,Quantity,MakerID from DigCameras,Maker where Maker =MakerID" UpdateCommand="UPDATE [DigCameras] SET [CamName] = @CamName, [MakerID] = @MakerID, [MegaPix] = @MegaPix, [Price] = @Price, [Quantity] = @Quantity WHERE [CamID] = @CamID"
DeleteCommand ="Delete DigCameras where CamID=@CamID"
ConnectionString="<%$ ConnectionStrings:CamConnString %>" >
</asp:SqlDataSource>
I have never used the control GridView before, and I don't know if I have insertred the dropdownlist correctly. But I want to have a dropdownlist for the user to choose the Maker from the table Maker.
Please help me
And if you can explain thorougly, please do, what I need to do to make it work.
Thanks
Fia