Asp.net - 日历控件和2个gridview控件 [英] Asp.net - calendar control and 2 gridview controls

查看:92
本文介绍了Asp.net - 日历控件和2个gridview控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含3个控件的网页:



*日历控件

*游戏的Gridview控件(使用SqlDataSource1,设置为一个需要1个参数的存储过程:date)

*视频的Gridview控件(使用SqlDataSource2,设置为需要1个参数的存储过程:gameID)



这是我的预期功能:

*仅在启动时可见的控件是日历控件

*用户从日历控件中选择日期

*游戏网格视图变为可见,显示用户在日历控件中选择的日期的游戏

*用户在游戏网格视图中选择一行

*视频网格视图变为可见,显示游戏的可用视频



如果我删除日历控件,则游戏gridview和视频gridview之间的功能可按预期工作:



 <  < span class =code-leadattribute> asp:GridView     ID   =  GridView1    DataSourceID   =  SqlDataSource1    DataKeyNames   =  GameID < span class =code-attribute>   AutoGenerateSelectButton   =  True    runat   =   server    /  >  

< asp:SqlDataSource ID = SqlDataSource1 runat = server ConnectionString = <% $ ConnectionStrings:myConnectionString %> SelectCommand = usp_SeasonSchedule_GetGamesByDate SelectCommandType = StoredProcedure >
< SelectParameters >
< ; asp:参数 DefaultValue = 07-Oct-15 名称 = 日期 类型 = 日期时间 / >
< / 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 名称 = GameID ControlID = GridView1 / >
< / SelectParameters >
< span class =code-keyword><
/ asp:SqlDataSource >





然而,当我添加Calendar控件并更改时游戏gridview的数据源依赖于Calendar控件中选择的日期,Video gridview不再有效



 <   asp:日历    ID   =  Calendar1    runat   = 服务器 >  <   / asp:日历 >  

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

< asp:SqlDataSource ID = SqlDataSource1 runat = server ConnectionString = <% $ ConnectionStrings:myConnectionString < span class =code-pagedirective>%> SelectCommand = usp_SeasonSchedule_GetGamesByDate SelectCommandType = StoredProcedure >
< SelectParameters >
< asp:ControlParameter ControlID = Calendar1 DefaultValue = 名称 = date PropertyName = SelectedDate 类型 = 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 鲁纳t = server >
< SelectParameters >
< asp:ControlParameter 名称 = GameID ControlID = GridView1 / >
< / SelectParameters >
< / asp:SqlDataSo urce >







我哪里错了?



我的尝试:



Microsoft的教程:教程10:使用可选的Master GridView和详细信息DetailView(https://msdn.microsoft.com/en-us/library/aa581796.aspx)

解决方案的主/细节方案

ConnectionStrings:myConnectionString %> SelectCommand = usp_SeasonSchedule_GetGamesByDate SelectCommandType = StoredProcedure >
< SelectParameters >
< asp :参数 DefaultValue = 07-Oct-15 名称 = date 类型 = 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 = 服务器 >
< SelectParameters >
< asp:ControlParameter 名称 = GameID ControlID = GridView1 / >
< / SelectParameters >
< / asp:SqlDataSource >





但是,当我添加Calendar控件,并将Games gridview的数据源更改为依赖于Calendar控件中选择的日期时,Video gridview将不再工作



< asp:日历 ID = Calendar1 runat = server > < / asp:日历 >

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

< asp:SqlDataSource ID = SqlDataSource1 runat = server ConnectionString = <%


ConnectionStrings:myConnectionString %> SelectCommand = usp_SeasonSchedule_GetGamesByDate SelectCommandType = StoredProcedure >
< SelectParameters >
< asp:ControlParamete r ControlID = Calendar1 DefaultValue = 姓名 = date PropertyName = SelectedDate 类型 = 日期时间 / >
< /选择参数 >
< / asp:SqlDataSource >

< < span class =code-leadattribute> asp:GridView ID = GridView2 runat = server DataSourceID = SqlDataSource2 < span class =code-attribute> / >
< asp:SqlDataSource ID = SqlDataSource2 ConnectionString = <%


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: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: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)

解决方案

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: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="<%


这篇关于Asp.net - 日历控件和2个gridview控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆