checkboxlist

Yii 2 ActiveForm form field how to implement “select all” option in checkboxlist?

我们两清 提交于 2019-12-07 17:56:55
问题 Yii 2 ActiveForm form field how to implement "select all" option in checkboxlist? <?php $form = ActiveForm::begin([ 'id' => 'form-id', 'type' => ActiveForm::TYPE_HORIZONTAL, 'options' => ['class' => 'well'], ]); ?> <?php echo $form->field($model, 'MY_DESC', ['template' => "{label}\n{input}\n{hint}\n{error}"]) ->label(false) ->checkboxList($mylist, ['separator' => '<hr>']); ?> <?= Html::submitButton('submit', ['class' => 'btn btn-primary']) ?> <?php ActiveForm::end(); ?> 回答1: 1) Add checkbox

How do I bind a dictionary to a set of checkboxes using ASP.NET MVC?

梦想与她 提交于 2019-12-06 07:41:08
问题 My need is to 'bind' Dictionary<MyType, bool> to list of checkboxes in asp.net mvc. I'm confused about how to accomplish that. Could anyone help me? 回答1: Assuming that MyType has a string property named Name from which you will get the name of the checkbox. Note that I've changed this to preface it with MyType so we can easily distinguish it on the server. You may not need this step if you have another way to determine which fields are the checkboxes. <% foreach (var pair in model

Unable to start activity ComponentInfo: java.lang.NullPointerException

柔情痞子 提交于 2019-12-06 07:20:13
The Exception : Unable to start activity ComponentInfo{com.scytec.datamobile.vd.gui.android/com.scytec.datamobile.vd.gui.android.SelectedList}: java.lang.NullPointerException.. I just want to show checkbox list view and on every check it display "checked", simply but i don't know why this gives me an exception. public class SelectedList extends Activity implements IObserver{ private ListView machine_listview; ArrayAdapter<String> adapter; ArrayList<String> arrayListofMachines; ArrayList<String> arrayListofMachineNumbers; Vector<MDCMachineStatus> machineStatus_vector; Handler handler; private

Yii 2 ActiveForm form field how to implement “select all” option in checkboxlist?

不想你离开。 提交于 2019-12-05 19:37:04
Yii 2 ActiveForm form field how to implement "select all" option in checkboxlist? <?php $form = ActiveForm::begin([ 'id' => 'form-id', 'type' => ActiveForm::TYPE_HORIZONTAL, 'options' => ['class' => 'well'], ]); ?> <?php echo $form->field($model, 'MY_DESC', ['template' => "{label}\n{input}\n{hint}\n{error}"]) ->label(false) ->checkboxList($mylist, ['separator' => '<hr>']); ?> <?= Html::submitButton('submit', ['class' => 'btn btn-primary']) ?> <?php ActiveForm::end(); ?> 1) Add checkbox to your form like so: echo Html::checkbox(null, false, [ 'label' => 'Check all', 'class' => 'check-all', ]);

Several Checkboxes sharing the same name

坚强是说给别人听的谎言 提交于 2019-12-05 15:09:14
问题 According to the w3c "Several checkboxes in a form may share the same control name. Thus, for example, checkboxes allow users to select several values for the same property." However, if you do that, PHP will only take the last value. For example: <?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=

checkboxlist items as checked by default in codebehind asp.net

a 夏天 提交于 2019-12-05 03:19:35
In my page I have a CheckBoxList control and I have 7 items on it. I would like to set those 7 items as checked in my Page_load codebihind. my page: <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> Majid If you want to check some of those with some condition, You can use

Binding ngModel to Dynamic Checkbox List : Angular 2 / Typescript

天涯浪子 提交于 2019-12-04 18:55:28
问题 I'm not sure the proper way to bind and update a model where the checkboxes are dynamically generated. (This is a ASP.NET Core project with Angular 2 initially created using the Yeoman generator) Or a simple checkbox for that matter I have just found out. Below is stripped down code, which has a facility and timeslots. Each facility can have multiple timeslots. The timeslot checkbox list displays fine. The initial data indicates only one timeslot should be checked. But when I load up a

How do I bind a dictionary to a set of checkboxes using ASP.NET MVC?

南笙酒味 提交于 2019-12-04 11:45:05
My need is to 'bind' Dictionary<MyType, bool> to list of checkboxes in asp.net mvc. I'm confused about how to accomplish that. Could anyone help me? Assuming that MyType has a string property named Name from which you will get the name of the checkbox. Note that I've changed this to preface it with MyType so we can easily distinguish it on the server. You may not need this step if you have another way to determine which fields are the checkboxes. <% foreach (var pair in model.ChecboxDictionary) { %> <%= Html.CheckBox( "MyType." + pair.Key.Name, pair.Value ) %> <% } %> Controller (this uses

How to set multiple selected values in asp.net checkboxlist

倖福魔咒の 提交于 2019-12-04 01:18:37
I have a asp.net checkbox list bound to a linq to sql datasource and when I check the item count of my CheckBoxList on the page load event it is 0. I want to be able to set the selected items on my checkboxlist here but cannot. The datasource's selected event fires after the page load. If this is the case, how can I set the selected items on my list? If I set the SelectedValue to a value it only displays the last value as selected instead of all the values which are selected. How can I select multiple values in my checkboxlist in the pageload event? I know this is an old post but I had the

Populate checkboxlist with items from database?

荒凉一梦 提交于 2019-12-03 16:43:00
Ok, so I want to populate/bind some data to a checkboxlist but cannot seem to binf the right values? I want to populate it with the information from a ROW, not the whole column which is what's happening to me. Here's some code anyways to show you what the problem is. This is the code in the xaml <form id="form1" runat="server"> <div> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [Option1], [Option2], [Option3] FROM [Questions] WHERE ([QuestionID] = @QuestionID)"> <SelectParameters> <asp:Parameter