selectedvalue

set selected value in angular5 ng-select programmaticaly

為{幸葍}努か 提交于 2019-12-02 02:49:46
I'm using angular5 ng-select component: https://github.com/ng-select/ng-select and try to set the selected value (programatically) when the container component first loaded (kind of default selected value set in the model). I didn't find any relevant attribute for it or for the isSelected for each item. Here is my code (filtered): HTML: <ng-select [items]="filter.values" bindLabel="text" bindValue="id" class="input-md" [(ngModel)]="filter.selectedValue"></ng-select> Model: export class FilterData { Name : string; FormattedName : string; values : Filter[]; selectedValue : Filter = null;

Angular 4 - find selected value in dropdown

强颜欢笑 提交于 2019-12-01 11:12:52
I am using Angular 4 Reactive Forms to create a dropdown <select id="city" formControlName="city" (change)="onCitySelect($event)" > <option *ngFor="let city of cities" [ngValue]="city" > {{ city }} </option> </select> When a value is selected in the dropdown, I want to call a method and display the selected value. Here is my code to do this onCitySelect(event) { console.log(event.target.value); } I was expecting it to print the City name as shown in the dropdown. However, it seems it displays the index number as well. For instance, 2: London Instead of just London which is actually shown in

Angular 4 - find selected value in dropdown

懵懂的女人 提交于 2019-12-01 08:43:58
问题 I am using Angular 4 Reactive Forms to create a dropdown <select id="city" formControlName="city" (change)="onCitySelect($event)" > <option *ngFor="let city of cities" [ngValue]="city" > {{ city }} </option> </select> When a value is selected in the dropdown, I want to call a method and display the selected value. Here is my code to do this onCitySelect(event) { console.log(event.target.value); } I was expecting it to print the City name as shown in the dropdown. However, it seems it displays

C# getting selected value from dropdownlist in gridview asp net

人盡茶涼 提交于 2019-11-30 23:46:38
How can I change the value of a textbox whenever a dropdownlist within a gridview has its value changed? On page load, the textbox shows the selected value, but when I change the selection of the dropdownlist, the textbox value doesn't change. The code is below. <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns = "false"> <Columns> <asp:TemplateField HeaderText="Entry"> <ItemTemplate> <%# Container.DataItemIndex + 1 %> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Duty"> <ItemTemplate> <asp:DropDownList ID="duty" runat="server" OnLoad = "ddl1_load"

Html.DropDownList selected value not working using ViewBag

别说谁变了你拦得住时间么 提交于 2019-11-30 23:14:54
Well, after a couple hours reading stuff over here, trying unsuccessfully all the solutions, also found this article that i thought it would save my life... nothing. Long story short. Here is my View (all combinations) @Html.DropDownList("yearDropDown",(IEnumerable<SelectListItem>)ViewBag.yearDropDown) @Html.DropDownList("yearDropDownxxx",(IEnumerable<SelectListItem>)ViewBag.yearDropDown) @Html.DropDownList("yearDropDown",(<SelectList>)ViewBag.yearDropDown) @Html.DropDownList("yearDropDown") Here is my Controller public ActionResult(int year) { var years = new int[] { 2007, 2008, 2009, 2010,

value of select elements with “e.value” vs “e.options[e.selectedIndex].value”

こ雲淡風輕ζ 提交于 2019-11-30 22:52:41
Given the HTML: <select id="mySelect"> <option value="1">test1</option> <option value="2">test2</option> <option value="3">test3</option> </select> and the javascript: var e = document.getElementById('mySelect'); To get the value of the select I can use e.value and e.options[e.selectedIndex].value . I am aware that e.options[e.selectedIndex].value will give me the selected value (1,2 or 3) and e.options[e.selectedIndex].text would give me test1, test2, test3 depending on which is selected. Is it ok to use just e.value ? was this a problem in old browsers? which is more correct: e.value vs e

Html.DropDownList selected value not working using ViewBag

偶尔善良 提交于 2019-11-30 17:38:10
问题 Well, after a couple hours reading stuff over here, trying unsuccessfully all the solutions, also found this article that i thought it would save my life... nothing. Long story short. Here is my View (all combinations) @Html.DropDownList("yearDropDown",(IEnumerable<SelectListItem>)ViewBag.yearDropDown) @Html.DropDownList("yearDropDownxxx",(IEnumerable<SelectListItem>)ViewBag.yearDropDown) @Html.DropDownList("yearDropDown",(<SelectList>)ViewBag.yearDropDown) @Html.DropDownList("yearDropDown")

Problems with AJAX CascadingDropDown and DropDownList SelectedValue in EditItemTemplate

北慕城南 提交于 2019-11-29 16:05:56
I am having problem in EditItemTemplate of FormView. When I use such code in InsertItemTemplate everything works: <asp:DropDownList ID="Lic_PosiadaczLicencjiIDDropDownList" runat="server" SelectedValue='<%# Bind("Lic_PosiadaczLicencjiID") %>' /> <asp:CascadingDropDown ID="CascadingDropDown1" runat="server" TargetControlID="Lic_PosiadaczLicencjiIDDropDownList" Category="Knt_Kod" ServicePath="~/ManagerLicencjiService.asmx" ServiceMethod="GetKontrahenci"> </asp:CascadingDropDown> But when I use exactly the same code in EditItemTemplate I am getting an error that SelectedValue is wrong cause it

ASP:DropDownList in ItemTemplate: Why is SelectedValue attribute allowed?

拈花ヽ惹草 提交于 2019-11-29 13:17:54
This piece of code <asp:DropDownList runat="server" ID="testdropdown" SelectedValue="2"> <asp:ListItem Text="1" Value="1"></asp:ListItem> <asp:ListItem Text="2" Value="2"></asp:ListItem> <asp:ListItem Text="3" Value="3"></asp:ListItem> </asp:DropDownList> yields this error: The 'SelectedValue' property cannot be set declaratively. Yet, this is a legal and commonly used edit template for databound GridViews. The SelectedValue attribute certainly appears to be declaratively set here. <EditItemTemplate> <asp:DropDownList runat="server" ID="GenreDropDownList" DataSourceID="GenreDataSource"

.NET 3.5 Listbox Selected Values (Winforms)

你说的曾经没有我的故事 提交于 2019-11-29 08:45:33
I am BATTLING to get the selected values (please note VALUES not TEXT) from a Winforms Listbox that has multi-select enabled and has been bound to a database table getting the Name (as DisplayMember) and ID (as ValueMember) - I need the ID of the selected items. The listbox control has properties for SelectedValue to get one of the selected items values, but not for all selected items values. The SelectedItems property returns a Listbox.SelectedObjectCollection from which I cannot seem to extract the VALUES of the items. Please help! Thanks. Try casting each object in the collection to the