asp.net - How to retreive values in DropwnList for all selected chekboxes, and return to default when unchecked?
问题描述
Default dropdownlist values include locations for all books. When I select a checkbox the the dropdownlist should populate only the locations where that book is available.In back-end, My Stored procedure is working fine for single parameter and multiple values.
But in UI, I can get locations for only one checkbox, if I click second checkbox the dropdown list does not include the value for that second checkbox.
Also when I unclick all it should return to default. Any hint or help will be appreciated.
<label>BooksLocations</label>
<asp:DropDownList runat="server" ID="drpdwnListLocationBooks" CssClass="formcontrol">
</asp:DropDownList>
<label>Books</label>
<asp:CheckBoxList runat="server" ID="chkboxListbookStatus">
<asp:ListItem Text="Book A"></asp:ListItem>
<asp:ListItem Text="Book B"></asp:ListItem>
<asp:ListItem Text="Book C"></asp:ListItem>
</asp:CheckBoxList>
解决方案
添加以下代码
<asp:CheckBoxList runat="server" ID="chkboxListbookStatus"
AutoPostBack="True" OnSelectedIndexChanged="chkboxListbookStatus_SelectedIndexChanged">
然后在后面的代码中
protected void chkboxListbookStatus_SelectedIndexChanged(object sender, EventArgs e)
{
CheckBoxList list = sender as CheckBoxList;
ListItem box = list.SelectedItem;
//add code to get data from SP to fill data in dropdown
}
推荐阅读
- javascript - 无论 CSP 中有什么,Cordova 都不会获取任何 base64
- maven - 将 Active Choices 反应参数插件与 Maven 元数据插件一起使用
- c - 1000位数字的13个相邻数字的最大乘积
- amazon-web-services - 实现 Lambda 函数以通过 SSM 运行命令
- javascript - 仅出于某些原因使网站的 SourceMap 可见
- python-3.x - 斐波那契快速递归程序的复杂性
- gtk - 如何从具有后备功能的 GIcon 创建 GtkImage?
- android - Google 脚本在第 14 行返回错误,但第 14 行没有代码
- go - 在 golang 中调用带有 WMI 类参数的方法
- traefik - 完全从命令行配置 Traefik