So based on what is selected in a radiobuttonlist i want the select command to change for my datasource. The problem I'm facing is that if i set the default selected radio button the query will work for that
my radiobuttonlist , user (dropdownlist are all located in an update panel that is not updated after the button is clicked
this my button code
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>
开发者_StackOverflow中文版<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>
I bet your radiobuttonlist is not in the updatepanel and that's why it is not updated. To update the radiobuttonlist, you need to put it in an updatepanel.
You need to specify the event Name of the control: Event="SelectedIndexChanged"
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddivision" Event="SelectedIndexChanged" />
</Triggers>
加载中,请稍侯......
精彩评论