datasource select命令不会随单选按钮列表而改变

时间:2011-05-10 14:15:57

标签: asp.net vb.net

因此,基于radiobuttonlist中选择的内容,我希望select命令可以更改为我的数据源。我面临的问题是,如果我设置默认选择的单选按钮,则查询将适用于该

我的radiobuttonlist,用户(下拉列表都位于更新面板中,单击按钮后未更新

这是我的按钮代码

    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>

1 个答案:

答案 0 :(得分:0)

我敢打赌你的radiobuttonlist不在updatepanel中,这就是为什么它没有更新。要更新radiobuttonlist,您需要将其放在updatepanel

您需要指定控件的事件名称:Event="SelectedIndexChanged"

<Triggers>
  <asp:AsyncPostBackTrigger ControlID="ddivision" Event="SelectedIndexChanged" />
</Triggers>