Asp.net 数据源选择命令不会随收音机按钮列表更改
因此,根据radiobuttonlist中选择的内容,我希望为我的数据源更改select命令。我面临的问题是,如果我设置默认选中的单选按钮,查询将适用于该按钮 我的radiobuttonlist、user dropdownlist都位于更新面板中,单击按钮后该面板不会更新 这是我的按钮代码Asp.net 数据源选择命令不会随收音机按钮列表更改,asp.net,vb.net,Asp.net,Vb.net,因此,根据radiobuttonlist中选择的内容,我希望为我的数据源更改select命令。我面临的问题是,如果我设置默认选中的单选按钮,查询将适用于该按钮 我的radiobuttonlist、user dropdownlist都位于更新面板中,单击按钮后该面板不会更新 这是我的按钮代码 If user.Text = "ALL" Then SqlDataSource22.SelectCommand = "SELECT * FROM [dashbo
If user.Text = "ALL" Then
SqlDataSource22.SelectCommand = "SELECT * FROM [dashboardtasks] WHERE [completed] = 'NO'"
SqlDataSource23.SelectCommand = "SELECT * FROM [dashboardtasks] WHERE (([agent] = @agent) AND (([completed] = 'YES') or ([completed] = 'XL')))"
Else
If RadioButtonList1.SelectedIndex = 0 Then
SqlDataSource22.SelectCommand = "SELECT * FROM [dashboardtasks] WHERE (([agent] = @agent) AND ([completed] = @completed))"
SqlDataSource23.SelectCommand = "SELECT * FROM [dashboardtasks] WHERE (([agent] = @agent) AND (([completed] = 'YES') or ([completed] = 'XL')))"
ElseIf RadioButtonList1.SelectedIndex = 1 Then
SqlDataSource22.SelectCommand = "SELECT * FROM [dashboardtasks] WHERE (([agent] = @agent) AND ([completed] = @completed) and tasktype = 'Air')"
SqlDataSource23.SelectCommand = "SELECT * FROM [dashboardtasks] WHERE (([agent] = @agent) AND (([completed] = 'YES') or ([completed] = 'XL')) and tasktype = 'Air')"
End If
End If
UpdatePanel1.Update()
UpdatePanel2.Update()
<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel5" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="Panel9" runat="server" Height="24px" Width="392px">
<asp:DropDownList ID="ddivision" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddivision_SelectedIndexChanged">
<asp:ListItem Selected="True">All</asp:ListItem>
<asp:ListItem Value="A">Club ABC</asp:ListItem>
<asp:ListItem Value="B">ABC Destinations</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="userslist" runat="server" Height="20px" Width="184px"></asp:DropDownList>
<asp:Button ID="updatediary" runat="server" Text="Update" /></asp:Panel>
<asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatColumns="5" >
<asp:ListItem>All</asp:ListItem>
<asp:ListItem Selected="True">Land</asp:ListItem>
<asp:ListItem>Air</asp:ListItem>
<asp:ListItem>Cruise</asp:ListItem>
</asp:RadioButtonList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddivision" />
</Triggers>
</asp:UpdatePanel>
我打赌你的RadioButton列表不在updatepanel中,这就是为什么它没有更新。要更新radiobuttonlist,需要将其放入updatepanel中
您需要指定控件的事件名称:event=SelectedIndexChanged
我试着它不起作用,我甚至用自动回邮更新了radiobuttonlist和DropDownList的面板。你能发布你的完整表单设计吗?有什么能帮我解决这个问题的吗?它让我发疯了。修改答案,现在试试。若问题仍然存在,请将完整的c代码发布到“System.Web.UI.UpdatePanelTriggerCollection”中。错误7文字内容不允许出现在“System.Web.UI.UpdatePanelTriggerCollection”中。
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddivision" Event="SelectedIndexChanged" />
</Triggers>