我有一个下拉列表:
<asp:DropDownList ID="userNameDropDown" runat="server" DataSourceID="SqlDataSource1"
DataTextField="Name" DataValueField="PK_User" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"
AutoPostBack="true">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
SelectCommand="SELECT [Name], [PK_User] FROM [User] ORDER BY [Name]"></asp:SqlDataSource>
还有一个带有多个面板的页面。在第一个面板上,此菜单影响如何将信息输入数据库。在第二个面板上,它会影响数据的显示方式:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource4"
AllowPaging="True" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None"
BorderWidth="1px" CellPadding="3" CellSpacing="2" OnRowDeleting="GridView1_OnRowDeleting" OnRowEditing="GridView1_OnRowEditing"
DataKeyNames="PK_DailyTaskHours, PK_NonScrumStory" AutoPostBack="false">
<Columns>
<asp:BoundField DataField="Catagory" HeaderText="Support Catagory" SortExpression="Catagory" />
<asp:BoundField DataField="AppName" HeaderText="Application Name" SortExpression="IncidentNumber" />
<asp:BoundField DataField="IncidentNumber" HeaderText="Incident #" SortExpression="IncidentNumber" />
<asp:BoundField DataField="Hours" HeaderText="Hours" SortExpression="Hours" />
<asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
<asp:BoundField DataField="CreatedDate" HeaderText="Created Date" SortExpression="CreatedDate" />
<asp:CommandField ShowEditButton="True" />
<asp:CommandField ShowDeleteButton="True" />
</Columns>
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FFF1D4" />
<SortedAscendingHeaderStyle BackColor="#B95C30" />
<SortedDescendingCellStyle BackColor="#F1E5CE" />
<SortedDescendingHeaderStyle BackColor="#93451F" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
SelectCommand="SELECT [NonScrumStory].[IncidentNumber], [NonScrumStory].[Description], [NonScrumStory].[CreatedDate],
[DailyTaskHours].[Hours], [Application].[AppName], [SupportCatagory].[Catagory], [DailyTaskHours].[PK_DailyTaskHours],
[NonScrumStory].[PK_NonScrumStory] FROM [NonScrumStory], [DailyTaskHours], [Application], [SupportCatagory] WHERE
([NonScrumStory].[UserId] = @userIdSelected) AND ([NonScrumStory].[PK_NonScrumStory] = [DailyTaskHours].[NonScrumStoryId])
AND ([NonScrumStory].[CatagoryId] = [SupportCatagory].[PK_SupportCatagory]) AND
([NonScrumStory].[ApplicationId] = [Application].[PK_Application]) AND ([NonScrumStory].[Deleted] != 1)"
DeleteCommand="UPDATE [NonScrumStory] SET [Deleted] = 1 WHERE (PK_NonScrumStory = @nonScrumStoryPK);
UPDATE [DailyTaskHours] SET [Deleted] = 1 WHERE (PK_DailyTaskHours = @dailyTaskHoursPK); ">
<SelectParameters>
<asp:QueryStringParameter Name="userIdSelected" Type="String" />
</SelectParameters>
<DeleteParameters>
<asp:QueryStringParameter Name="dailyTaskHoursPK" Type="String" />
<asp:QueryStringParameter Name="nonScrumStoryPK" Type="String" />
</DeleteParameters>
</asp:SqlDataSource>
这是页面后端进行更改的代码:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
//change WHERE clause for SQL statement that effects grid view based on drop down menu selection
SqlDataSource4.SelectParameters["userIdSelected"].DefaultValue = userNameDropDown.SelectedItem.Value;
}
有显示和隐藏面板的单选按钮。当显示 gridview 的面板打开时,下拉菜单中的更改会反映并且 gridview 会更新。
当另一个单选按钮被选中并且 gridview 面板被隐藏并且用户更改下拉菜单时,不会反映更新。您再次更改单选按钮并显示 gridview 面板,正在显示上一个表格。我该如何解决?