The Reviews.aspx returns an error:
Code:
The DataSourceID of 'DropDownList1' must be the ID of a control of type IDataSource. A control with ID 'SqlDataSource1' could not be found.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: The DataSourceID of 'DropDownList1' must be the ID of a control of type IDataSource. A control with ID 'SqlDataSource1' could not be found.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): The DataSourceID of 'DropDownList1' must be the ID of a control of type IDataSource. A control with ID 'SqlDataSource1' could not be found.]
System.Web.UI.WebControls.DataBoundControl.GetDataSource() +8559526
System.Web.UI.WebControls.DataBoundControl.ConnectToDataSourceView() +37
System.Web.UI.WebControls.DataBoundControl.OnLoad(EventArgs e) +19
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
My Source Code I think the connection string for SqlDataSource1 is missing, but I am not certain where I should put that. When I put it after the ASP link for SqlDataSource2, I get a 'not well formed' error which tells me it I may be tying the data source to the wrong control.
Code:
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True" AutoPostBack="True"
DataSourceID="SqlDataSource1" DataTextField="Name" DataValueField="Id">
<asp:ListItem Value="">Please make a selection</asp:ListItem>
</asp:DropDownList>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Id" DataSourceID="SqlDataSource2">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True" SortExpression="Id" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="Summary" HeaderText="Summary" SortExpression="Summary" />
<asp:BoundField DataField="Body" HeaderText="Body" SortExpression="Body" />
<asp:BoundField DataField="GenreId" HeaderText="GenreId" SortExpression="GenreId" />
<asp:CheckBoxField DataField="Authorized" HeaderText="Authorized" SortExpression="Authorized" />
<asp:BoundField DataField="CreateDateTime" HeaderText="CreateDateTime" SortExpression="CreateDateTime" />
<asp:BoundField DataField="UpdateDateTime" HeaderText="UpdateDateTime" SortExpression="UpdateDateTime" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:PlanetWroxConnectionString1 %>"
SelectCommand="SELECT * FROM [Review] WHERE ([GenreId] = @GenreId)">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="GenreId" PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>