Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
I have a web page with 3 controls:

* Calendar control
* Gridview control for games (uses SqlDataSource1, set to a stored procedure that requires 1 parameter: date)
* Gridview control for videos (uses SqlDataSource2, set to a stored procedure that required 1 parameter: gameID)

This is my intended functionality:
* only control visible at start-up is the calendar control
* user selects a date from the calendar control
* the Game gridview becomes visible, showing games on the date the user selected in the Calendar control
* the user selects a row in the Games gridview
* the Video gridview becomes visible, showing available videos for the game

If I remove the Calendar control, the functionality between the Games gridview and the Videos gridview works as intended:

ASP.NET
<asp:GridView ID="GridView1" DataSourceID="SqlDataSource1" DataKeyNames="GameID" AutoGenerateSelectButton="True" runat="server" />

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:myConnectionString %>" SelectCommand="usp_SeasonSchedule_GetGamesByDate" SelectCommandType="StoredProcedure">
    <SelectParameters>
        <asp:Parameter DefaultValue="07-Oct-15" Name="date" Type="DateTime" />
    </SelectParameters>
</asp:SqlDataSource> 

<asp:GridView ID="GridView2" runat="server" DataSourceID="SqlDataSource2" />

<asp:SqlDataSource ID="SqlDataSource2" ConnectionString="<%$Connectionstrings:myConnectionString%>" SelectCommand="usp_Videos_GetVideoForGame" SelectCommandType="StoredProcedure" runat="server">
	<SelectParameters>
		<asp:ControlParameter Name="GameID" ControlID="GridView1"/>
	</SelectParameters>
</asp:SqlDataSource>


However, when I add the Calendar control, and change the datasource of the Games gridview to be dependent on the date selected in the Calendar control, the Video gridview no longer works

ASP.NET
<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>

<asp:GridView ID="GridView1" DataSourceID="SqlDataSource1" DataKeyNames="GameID" AutoGenerateSelectButton="True" runat="server" />

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:myConnectionString %>" SelectCommand="usp_SeasonSchedule_GetGamesByDate" SelectCommandType="StoredProcedure">
    <SelectParameters>
        <asp:ControlParameter ControlID="Calendar1" DefaultValue="" Name="date" PropertyName="SelectedDate" Type="DateTime" />
    </SelectParameters>
</asp:SqlDataSource> 

<asp:GridView ID="GridView2" runat="server" DataSourceID="SqlDataSource2" />
    <asp:SqlDataSource ID="SqlDataSource2" ConnectionString="<%$Connectionstrings:myConnectionString%>" SelectCommand="usp_Videos_GetVideoForGame" SelectCommandType="StoredProcedure" runat="server">
    <SelectParameters>
        <asp:ControlParameter Name="GameID" ControlID="GridView1"/>
    </SelectParameters>
</asp:SqlDataSource>



Where am I going wrong?

What I have tried:

Microsoft's tutorial: Tutorial 10: Master/Detail Using a Selectable Master GridView with a Details DetailView (https://msdn.microsoft.com/en-us/library/aa581796.aspx)
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900