我目前正面临一个问题.如何从asp.net复选框列表中获取最新选定的值?
从循环到复选框列表的项目,我可以获得最高选择的索引及其值,但不希望用户从低到高的索引顺序选择复选框.那么,如何处理呢?
是否有任何事件捕获系统可以帮助我识别生成事件的确切列表项?
根据w3c"表单中的几个复选框可以共享相同的控件名称.因此,例如,复选框允许用户为同一属性选择多个值." 但是,如果这样做,PHP将只采用最后一个值.例如:
<?php
if ($_POST) {
echo "<pre>";
print_R($_POST);
echo "</pre>";
}
?>
<form action="" method = "post">
<input type="checkbox" name="pet" value="dog" />Dog<br />
<input type="checkbox" name="pet" value="Cat" />Cat<br />
<input type="checkbox" name="pet" value="bird" />bird<br />
<input type="checkbox" name="pet" value="iguana" />iguana<br />
<input type="submit" />
</form>
Run Code Online (Sandbox Code Playgroud)
如果您提交该表单,您将看到只会设置最后一个显示的复选框.浏览器将它们全部发送,但它们会相互覆盖.因此,将相同名称设置为多个复选框可能会导致问题.它总是这样吗?我似乎记得实际上可以将所有值作为数组发送.
我知道你可以在名称的末尾添加一个[]来创建一个值数组:
<?php
if ($_POST) {
echo "<pre>";
print_R($_POST);
echo "</pre>";
}
?>
<form action="" method = "post">
<input type="checkbox" name="pet[]" value="dog" />Dog<br />
<input type="checkbox" name="pet[]" value="Cat" />Cat<br />
<input type="checkbox" name="pet[]" value="bird" …Run Code Online (Sandbox Code Playgroud) 我有一个asp.net复选框列表绑定到linq到sql数据源,当我在页面加载事件检查我的CheckBoxList的项目计数时它是0.我希望能够在我的复选框列表中设置所选项目,但不能.
页面加载后,将触发数据源的选定事件.如果是这种情况,如何在列表中设置所选项目?
如果我将SelectedValue设置为一个值,它只显示最后一个选定的值而不是所有选定的值.如何在pageload事件中的checkboxlist中选择多个值?
我想知道检查CheckBoxList控件是否有任何检查项目的最快/最简单的方法,我说的是整个复选框列表,而不是一个复选框.
我在Windows窗体应用程序中使用CheckBoxList,并尝试为其应用数据源.
有一个DataTable,"DT",以列id,name并且ischecked,我用这样的代码:
((ListBox)MyCheckBoxList).DataSource = dt;
((ListBox)MyCheckBoxList).DisplayMember = "name";
((ListBox)MyCheckBoxList).ValueMember = "id";
Run Code Online (Sandbox Code Playgroud)
如何为MyCheckBoxList中的所有项设置CheckState?
我将此值保留在我的数据表中,并希望将它们与MyCheckBoxList链接.
我尝试检查ASP.NET CheckboxList中的多个值,但我不能.
我写 :
chkApplications.SelectedValue = 2;
chkApplications.SelectedValue = 6;
Run Code Online (Sandbox Code Playgroud)
但它只选择值为'6'的项目有
什么问题?
如何使用复选框从数据框或表中选择数据行?我已经完成了以下代码,但似乎复选框项目是列,并没有真正显示结果.
谢谢你的帮助.
shinyServer(function(input, output) {
dataset<-reactive({
data(cars)
cars
})
output$choose_data <- renderUI({
checkboxGroupInput("dtab", "Data Table", dataset())
})
dataset2<-reactive({
input$dtab
})
output$data_table <- renderTable({
data2()
})
})
Run Code Online (Sandbox Code Playgroud)
shinyUI(pageWithSidebar(
headerPanel(""),
sidebarPanel(
uiOutput("choose_data"),
br()
),
mainPanel(
wellPanel("Data", tableOutput("data_table")
))))
Run Code Online (Sandbox Code Playgroud) 我不确定绑定和更新动态生成复选框的模型的正确方法.(这是一个最初使用Yeoman生成器创建的Angular 2的ASP.NET Core项目)或者我刚刚发现的一个简单的复选框.
下面是剥离代码,它有一个设施和时间段.每个设施可以有多个时隙.时间段复选框列表显示正常.初始数据表明只应检查一个时隙.但是当我加载一个设施时,所有的时间段都会被检查.它们没有像我预期的那样与ngModel绑定.
代码说明我有两个来自api的对象(设施和时间段),我绑定到接口.为简单起见,它们的属性显着降低:
export interface IFacility {
id: number,
name: string,
haselectric: boolean,
timeslotids: number[],
timeslots: ITimeslot[]
}
export interface ITimeslot {
id: number,
timeslotname: string
}
Run Code Online (Sandbox Code Playgroud)
这是Timeslots的JSON数据:
[{"id":1,"timeslotname":"Daily"},{"id":2,"timeslotname":"Hourly"},{"id":4,"timeslotname":"Market"}]
Run Code Online (Sandbox Code Playgroud)
这是在更新之前单个Facility的JSON数据:
{"id":2,"name":"Clements Building","haselectric":true,"timeslotids":[1],"timeslots":[{"id":1,"timeslotname":"Daily"}]}
Run Code Online (Sandbox Code Playgroud)
用于编辑设施的组件(facility.component.html):
<form #form="ngForm" (ngSubmit)="submitForm()" *ngIf="formactive">
<input type="hidden" [(ngModel)]="updatedfacility.id" #id="ngModel" name="id" />
<div class="form-group">
<label for="name">Facility Name *</label>
<input type="text" class="form-control input-lg" [(ngModel)]="updatedfacility.name" #name="ngModel" name="name" placeholder="Facility Name *">
</div>
<div class="form-group">
<label for="exhibitspaces">Has Electric *</label>
<input type="checkbox" class="form-control input-lg" [(ngModel)]="updatedfacility.haselecric" #haselectric="ngModel" name="haselectric">
</div> …Run Code Online (Sandbox Code Playgroud) 我有一个HTML复选框列表,我想以下列格式显示:
Click all that apply:
Title A Title B
Option 1 [ ] [ ]
Option 2 [ ] [ ]
Option 3 [ ] [ ]
我想知道在语义上编码这个的最佳方法是什么?
我已经看到了一个关于语义正确的复选框的相关问题,但这没有考虑标题.
有任何想法吗?
在我的页面中,我有一个CheckBoxList控件,我有7个项目.我想在我的Page_load代码生成中设置这7个项目.
我的页面:
<asp:CheckBoxList ID="WeeklyCondition" runat="server">
<asp:ListItem Value="1">Sat</asp:ListItem>
<asp:ListItem Value="2">Sun</asp:ListItem>
<asp:ListItem Value="3">Mon</asp:ListItem>
<asp:ListItem Value="4">Tue</asp:ListItem>
<asp:ListItem Value="5">Wed</asp:ListItem>
<asp:ListItem Value="6">Thu</asp:ListItem>
<asp:ListItem Value="7">Fri</asp:ListItem>
</asp:CheckBoxList>
Run Code Online (Sandbox Code Playgroud) checkboxlist ×10
asp.net ×5
c# ×3
html ×2
.net ×1
.net-3.5 ×1
angular ×1
checkbox ×1
code-behind ×1
datasource ×1
dynamic ×1
forms ×1
ngmodel ×1
php ×1
r ×1
selecteditem ×1
semantics ×1
shiny ×1
typescript ×1
winforms ×1