When I select a Country from the listbox1 then second listbox should display states from the selected country - silverlight-5.0

I am Using MVVM Pattern.
when I select a Country from the listbox1 then second listbox
will display states from the selected country.
ListBox For Country
<pmControls:pmListBox x:Name="countryListBox" Grid.Row="1" Margin="3" ItemsSource="{Binding Countries}" SelectedItem="{Binding SelectedCountry,Mode=TwoWay}" >
<pmControls:pmListBox.ItemTemplate >
<DataTemplate >
<Button Command="{Binding DataContext.GetAllStatesCommand,ElementName=countryListBox}" Margin="3" Width="100" Height="25" Content="{Binding Title}" >
</Button>
</DataTemplate>
</pmControls:pmListBox.ItemTemplate>
</pmControls:pmListBox>
ListBox For State
<pmControls:pmListBox x:Name="stateListBox" Grid.Row="1" Margin="3" ItemsSource="{Binding States}">
<pmControls:pmListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding StateTitle}" ></TextBlock>
</DataTemplate>
</pmControls:pmListBox.ItemTemplate>
</pmControls:pmListBox>
In ModelView these are my commands:
command to get all Countries:
public void getCountries()
{
CountryServiceClient client = new CountryServiceClient();
client.GetCountryDetailsCompleted += (clientS, eventE) =>
{
if (eventE.Error == null)
{
foreach (var item in eventE.Result)
{
countries.Add(item);
}
}
};
client.GetCountryDetailsAsync();
}
command to get all states for selected Country:
public void ExecutegetAllStatesCommand(EventToCommandArgs args)
{
selectedState = new States();
states = new ObservableCollection<States>();
int cntry_id = this.SelectedCountry.Country_Id;
StateServiceClient client = new StateServiceClient();
client.GetStatesCompleted += (clientS, eventE) =>
{
if (eventE.Error == null)
{
foreach (var item in eventE.Result)
{
states.Add(item);
}
}
};
client.GetStatesAsync(cntry_id);
}
Here i got the data correctly in my list states but it doesnt appears on Xaml.
Please help.

You mentioned that the 'states' are being set correctly in the viewmodel, in that case the problem could be one of the following:
I noticed you are binding to 'States' (upper case S) and your code behind sets to 'states' (lower case S).
Have you implemented the INotifyPropertyChanged for the viewmodel and call the propertychanged event handler
Try handling the CollectionChanged of the ObservableCollection that you are adding States to as the propertychanged will not automatically trigger when adding items.

Related

Binding a List in a ObservableCollection in XAML - Specified cast not valid exception

I have an ObservableCollection<List<Model>> Data in my ViewModel.
In my Page I need a CarouselView, in which each ItemTemplate shows the data of the Data list in a ListView.
Currently, I am doing that in that way:
<CarouselView ItemsSource="{Binding Data}">
<CarouselView.ItemTemplate>
<DataTemplate>
<StackLayout>
...
<ListView ItemsSource="{Binding .}">
...
</ListView>
</StackLayout>
</DataTemplate>
</CarouselView.ItemTemplate>
</CarouselView>
In the way I am doing that I get a "Specified cast not valid" exception, in which I see the following additional information:
{System.InvalidCastException: Specified cast is not valid.
at (wrapper castclass) System.Object.__castclass_with_cache(object,intptr,intptr)
at Xamarin.Forms.Internals.TemplatedItemsList`2[TView,TItem].ActivateContent (System.Int32 index, System.Object item) [0x00032]
in <62e3629c74b84e3d834046331d2bb5f8>:0
at Xamarin.Forms.Internals.TemplatedItemsList`2[TView,TItem].CreateContent (System.Int32 index, System.Object item, System.Boolean insert) [0x00000]
in <62e3629c74b84e3d834046331d2bb5f8>:0
at Xamarin.Forms.Internals.TemplatedItemsList`2[TView,TItem].GetOrCreateContent (System.Int32 index, System.Object item) [0x00023]
in <62e3629c74b84e3d834046331d2bb5f8>:0
at Xamarin.Forms.Internals.TemplatedItemsList`2[TView,TItem].get_Item (System.Int32 index) [0x0000e]
in <62e3629c74b84e3d834046331d2bb5f8>:0
at Xamarin.Forms.Platform.iOS.ListViewRenderer+ListViewDataSource.GetCellForPath (Foundation.NSIndexPath indexPath) [0x00007]
in D:\a\_work\1\s\Xamarin.Forms.Platform.iOS\Renderers\ListViewRenderer.cs:1397
at Xamarin.Forms.Platform.iOS.ListViewRenderer+ListViewDataSource.GetCell (UIKit.UITableView tableView, Foundation.NSIndexPath indexPath) [0x00021]
in D:\a\_work\1\s\Xamarin.Forms.Platform.iOS\Renderers\ListViewRenderer.cs:1105
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.Type principalClass, System.Type delegateClass) [0x0003b]
in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:85
at App.iOS.Application.Main (System.String[] args) [0x00001]
in <Path>\Main.cs:18 }
The Model holds only string values, so the exception cannot come from this.
I'm not sure why you're getting that specific exception. I couldn't get the ListView inside of a CarouselView to work either.
However, it works when you use a bindable StackLayout instead of a ListView. My guess is that the bindable StackLayout doesn't support scrolling and thus doesn't fight with the CarouselView but I don't know.
MainPage, MainViewModel and items
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Xamarin.Forms;
namespace App1
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
}
public class MainViewModel
{
public ObservableCollection<Item> Data { get; }
public MainViewModel()
{
Data = new ObservableCollection<Item>(GenerateItems());
}
private IEnumerable<Item> GenerateItems()
{
return Enumerable.Range(1, 10)
.Select(a => new Item
{
ItemTitle = $"Item {a}",
SubItems = Enumerable.Range(1, 10).Select(b => new SubItem { SubItemTitle = $"SubItem {b}" }).ToList()
});
}
}
public class Item
{
public string ItemTitle { get; set; }
public List<SubItem> SubItems { get; set; }
}
public class SubItem
{
public string SubItemTitle { get; set; }
}
}
MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
x:Class="App1.MainPage"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:App1">
<ContentPage.BindingContext>
<local:MainViewModel />
</ContentPage.BindingContext>
<CarouselView ItemsSource="{Binding Data}">
<CarouselView.ItemTemplate>
<DataTemplate>
<StackLayout>
<Label Text="{Binding ItemTitle}" />
<StackLayout BindableLayout.ItemsSource="{Binding SubItems}">
<BindableLayout.ItemTemplate>
<DataTemplate>
<Label Text="{Binding SubItemTitle}" />
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
</StackLayout>
</DataTemplate>
</CarouselView.ItemTemplate>
</CarouselView>
</ContentPage>
Result:

Xamarin Forms Listview Items Not Displaying

I have a list in my Xamarin Forms app that I have being bound to data. This all works and I know I am getting data because if I tap on the screen the list shows the data, but I assume the list should show each item without having to tap on the screen.
Here is my xaml:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="PDInstall.Views.LayoutsPage"
Title="Layouts">
<ContentPage.Content>
<StackLayout>
<ListView x:Name="layoutsList" IsPullToRefreshEnabled="True"
Refreshing="layoutsList_Refreshing" ItemTapped="layoutsList_ItemTappedAsync">
<ListView.ItemTemplate>
<DataTemplate>
<TextCell Text="{Binding Name}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage.Content>
</ContentPage>
And here is my code behind:
public LayoutsPage (Job job)
{
InitializeComponent ();
_job = job;
Task.Run(() => GetLayoutsListAsync());
}
private async Task GetLayoutsListAsync()
{
if(CrossConnectivity.Current.IsConnected)
{
layoutsList.IsRefreshing = true;
IList<CloudBlockBlob> layouts = await azureFileUpload.ListJobBlobsAsync(_job.JobId);
IList<CloudEditableBlob> layoutList = new List<CloudEditableBlob>();
foreach(var item in layouts)
{
CloudEditableBlob editableBlob = new CloudEditableBlob();
editableBlob.Name = item.Name.Replace(_job.JobId.ToString() + ": ", "");
editableBlob.Container = item.Container;
editableBlob.Parent = item.Parent;
editableBlob.StorageUri = item.StorageUri;
editableBlob.Uri = item.Uri;
layoutList.Add(editableBlob);
}
layoutsList.IsRefreshing = false;
await Task.Run(() => layoutsList.ItemsSource = layoutList);
}
else
{
await DisplayAlert("No Internet Connection", "Please Reconnect to the Internet and re-open PDInstall", "OK");
}
layoutsList.EndRefresh();
}
I am getting a list of blobs from azure, they are just PDFs that we have stored. I get the list of blobs then I have to put it into a custom class, so I can change the name, then I put that into the list. This all works fine up until it tries to show the list and I get a blank page until I tap it where it then shows the list.
Does anyone know if I can programmatically do a tap or something to get that list to show? Or possibly another way to get the data show without having to tap on the screen?
Thanks in advance!
Replace
await Task.Run(() => layoutsList.ItemsSource = layoutList);
With
Device.BeginInvokeOnMainThread(() =>{ layoutsList.ItemsSource = layoutList; });

Top n Record from infragistics xamdatagrid in wpf

I have a wpf application in which I am using xamdatagrid of infragistics 14.2 to show data.
Sometimes grid may contains more than 1000 record.In same application I have given print option to print grid data.for printing I am using Report object of Infragistics.but before printing I am generating preview of print data using xamprintpreview control.
When grid contains large data (for 1000 record) it takes 35 seconds to generate preview for 1000 records.
I am binding Datatable to xamdatagrid(so you can say every record is a type of DataRow).
To speedup the process of preview I have an idea to show only top n record of grid in preview.but I am not able to fetch top n record of grid and store them in a datatable because if I take 10 record from datatable that I have binded to grid and user has applied some filter on grid so my preview mismatch with actual grid.
So please help me to fetch tp 10 record from grid that is currently displayed and store them in
datatable.
Thanks in advance...
You have a complete working example here
The keys are:
xamDataGrid.RecordManager.GetFilteredInDataRecords() gives your the filtered records. If you have not any filter it gives you all records.
Then Take(10) will take ten as much.
And I implemented ToDataTable as an extension method to convert the records taken to a datatable.
<Window x:Class="Stackoverflow1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:igDP="http://infragistics.com/DataPresenter"
xmlns:local="clr-namespace:Stackoverflow1"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<igDP:XamDataGrid x:Name="xamDataGrid" Loaded="XamDataGrid_Loaded">
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings FilterUIType="LabelIcons"/>
</igDP:XamDataGrid.FieldLayoutSettings>
<igDP:XamDataGrid.FieldSettings>
<igDP:FieldSettings AllowRecordFiltering="True" FilterLabelIconDropDownType="MultiSelectExcelStyle"/>
</igDP:XamDataGrid.FieldSettings>
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout>
<igDP:Field Name="Date"/>
<igDP:Field Name="Order"/>
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
<Button x:Name="btnPrintPreview" Content="Print Preview" Height="25" Width="100" Click="btnPrintPreview_Click"/>
</Grid>
</Window>
using Infragistics.Windows.DataPresenter;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Windows;
namespace Stackoverflow1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void XamDataGrid_Loaded(object sender, RoutedEventArgs e)
{
ObservableCollection<Item> list = new ObservableCollection<Item>();
for (int i = 0; i < 15; ++i)
{
list.Add(new Item { Date = DateTime.Now.AddDays(-i), Order = i});
}
xamDataGrid.DataSource = list;
}
private void btnPrintPreview_Click(object sender, RoutedEventArgs e)
{
IEnumerable<DataRecord> data = xamDataGrid.RecordManager.GetFilteredInDataRecords();
DataTable dt = data.Take(10).ToDataTable();
// DO YOUR PRINT PREVIEW
}
}
class Item
{
public DateTime Date { get; set; }
public int Order { get; set; }
}
static class Utils
{
public static DataTable ToDataTable(this IEnumerable<DataRecord> items)
{
if (items.Count() > 0)
{
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(typeof(Item));
DataTable table = new DataTable();
List<Item> list = new List<Item>();
foreach (var item in items)
{
list.Add((Item)item.DataItem);
}
foreach (PropertyDescriptor prop in properties)
table.Columns.Add(prop.Name, Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType);
foreach (Item item in list)
{
DataRow row = table.NewRow();
foreach (PropertyDescriptor prop in properties)
row[prop.Name] = prop.GetValue(item) ?? DBNull.Value;
table.Rows.Add(row);
}
return table;
}
return null;
}
}
}
In the code behind in an event handler:
private void Button_ClickEventHandler(object sender, MouseButtonEventArgs e)
{
DataTable table = new DataTable();
table.Columns.Add("Data1");
table.Columns.Add("Data2"); //etc... Add all columns necessary
var records = XamDataGridName.Records.Take(10);
foreach (var record in records)
{
var item = ((DataRecord)record).DataItem as DataType;
if (item != null)
{
table.Rows.Add(item.Data1, item.Data2);
}
}
}
Or using MVVM you can send the XamDataGrid.Records as a command parameter to a command in your view model and then loop through the data records, adding them to your data table.

MVC 4 - sorting with LINQ doesn't work with Ajax.BeginForm and my For loop

I writing some code with C# and MVC and I have button for sorting a list of data by asc and desc. The logic works in my controller, I am able to call the method that sorts the list and in the breakpoint I can see that it has been sorted.
But it's weird because when I loop through my list in the partial view it never works. I use a breakpoint in my view to make sure it's the same order of items which it is. But it's like the new values don't render to the screen.
TeamManagement.cshtml
#model Website.Models.modelTeamSelect
#{
ViewBag.Title = "Football App";
}
#section featured {
}
#using (Ajax.BeginForm("_PartialTeams",
new
{
model = this.Model
},
new AjaxOptions
{
HttpMethod = "POST",
UpdateTargetId = "divCreatedTeams",
InsertionMode = InsertionMode.Replace
}))
{
<div id="divTeams" style="float: left; padding: 10px;">
<h3>Create a new team:</h3>
#Html.LabelFor(m => m.team.TeamName)
#Html.TextBoxFor(m => m.team.TeamName)
<input type="submit" value="Add Team" name="btnSubmit" />
</div>
Html.RenderPartial("~/Views/Partials/_PartialTeams.cshtml");
}
_PartialTeams.cshtml
#model Website.Models.modelTeamSelect
<div id="divCreatedTeams" style="float: left; padding: 10px;">
<h3>Your created teams:</h3>
<input type="submit" value="Asc" name="btnSubmit" />
<input type="submit" value="Desc" name="btnSubmit" />
<br />
#if (Model.teams.Count > 0)
{
for (int i = 0; i < Model.teams.Count; i++)
{
#Html.EditorFor(m => m.teams[i].TeamName)
<input type="button" value="Update team name" name="btnSubmit"/>
<input type="button" value="Remove team" name="btnSubmit"/>
<br />
}
}
</div>
Sorting logic in my controller
[HttpPost]
public PartialViewResult _PartialTeams(string BtnSubmit, modelTeamSelect modelTeamSelect)
{
switch (BtnSubmit)
{
case "Add Team":
modelTeamSelect.teams.Add(modelTeamSelect.team);
break;
case "Asc":
FootballRepository = new Repository.FootballRepository();
modelTeamSelect.teams = FootballRepository.Sort(modelTeamSelect, BtnSubmit);
break;
case "Desc":
FootballRepository = new Repository.FootballRepository();
modelTeamSelect.teams = FootballRepository.Sort(modelTeamSelect, BtnSubmit);
break;
}
return PartialView("~/Views/Partials/_PartialTeams.cshtml", modelTeamSelect);
}
public List<Models.modelTeam> Sort(Models.modelTeamSelect modelTeamSelect, string sort)
{
switch (sort)
{
case "Asc":
modelTeamSelect.teams = modelTeamSelect.teams.OrderBy(t => t.TeamName).ToList();
break;
case "Desc":
modelTeamSelect.teams = modelTeamSelect.teams.OrderByDescending(t => t.TeamName).ToList();
break;
}
return modelTeamSelect.teams;
}
My main model with team collection
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Website.Models
{
public class modelTeamSelect
{
public modelTeamSelect()
{
teams = new List<modelTeam>();
team = new modelTeam();
}
public List<modelTeam> teams { get; set; }
public modelTeam team { get; set; }
}
}
My method Sort does it's job but in the view it never displays correctly. e.g. always wrong order.
Anyone have any ideas because I am stuck.
Screenshots
In the screenshots I click sort by Asc and you can see it says Newcastle as the first item in the list. But when the page renders it will say West Ham first even though it is iterating using the for loop.
All the Html helpers are preferring to use the ModelState values over the actual model values.
So even you have sorted in place your modelTeamSelect.teams in your action in the view #Html.EditorFor(m => m.teams[i].TeamName) call will use the original (before sorting) values form the ModelState.
The solution: if you are updating your action parameters in-place then just clear the ModelState before returning the View/PartialView:
[HttpPost]
public PartialViewResult _PartialTeams(string BtnSubmit,
modelTeamSelect modelTeamSelect)
{
// ... Do the sorting, etc.
ModelState.Clear();
return PartialView("~/Views/Partials/_PartialTeams.cshtml", modelTeamSelect);
}
You can read more about why the helpers are working like this in this article: ASP.NET MVC Postbacks and HtmlHelper Controls ignoring Model Changes

CheckBoxList multiple selections: how to model bind back and get all selections?

This code:
Html.CheckBoxList(ViewData.TemplateInfo.HtmlFieldPrefix, myList)
Produces this mark-up:
<ul><li><input name="Header.h_dist_cd" type="checkbox" value="BD" />
<span>BD - Dist BD Name</span></li>
<li><input name="Header.h_dist_cd" type="checkbox" value="SS" />
<span>SS - Dist SS Name</span></li>
<li><input name="Header.h_dist_cd" type="checkbox" value="DS" />
<span>DS - Dist DS Name</span></li>
<li><input name="Header.h_dist_cd" type="checkbox" value="SW" />
<span>SW - Dist SW Name </span></li>
</ul>
You can check multiple selections. The return string parameter Header.h_dist_cd only contains the first value selected. What do I need to do to get the other checked values?
The post method parameter looks like this:
public ActionResult Edit(Header header)
I'm assuming that Html.CheckBoxList is your extension and that's markup that you generated.
Based on what you're showing, two things to check:
The model binder is going to look for an object named Header with string property h_dist_cd to bind to. Your action method looks like Header is the root view model and not a child object of your model.
I don't know how you are handling the case where the checkboxes are cleared. The normal trick is to render a hidden field with the same name.
Also a nit, but you want to use 'label for="..."' so they can click the text to check/uncheck and for accessibility.
I've found that using extensions for this problem is error prone. You might want to consider a child view model instead. It fits in better with the EditorFor template system of MVC2.
Here's an example from our system...
In the view model, embed a reusable child model...
[AtLeastOneRequired(ErrorMessage = "(required)")]
public MultiSelectModel Cofamilies { get; set; }
You can initialize it with a standard list of SelectListItem...
MyViewModel(...)
{
List<SelectListItem> initialSelections = ...from controller or domain layer...;
Cofamilies = new MultiSelectModel(initialSelections);
...
The MultiSelectModel child model. Note the setter override on Value...
public class MultiSelectModel : ICountable
{
public MultiSelectModel(IEnumerable<SelectListItem> items)
{
Items = new List<SelectListItem>(items);
_value = new List<string>(Items.Count);
}
public int Count { get { return Items.Count(x => x.Selected); } }
public List<SelectListItem> Items { get; private set; }
private void _Select()
{
for (int i = 0; i < Items.Count; i++)
Items[i].Selected = Value[i] != "false";
}
public List<SelectListItem> SelectedItems
{
get { return Items.Where(x => x.Selected).ToList(); }
}
private void _SetSelectedValues(IEnumerable<string> values)
{
foreach (var item in Items)
{
var tmp = item;
item.Selected = values.Any(x => x == tmp.Value);
}
}
public List<string> SelectedValues
{
get { return SelectedItems.Select(x => x.Value).ToList(); }
set { _SetSelectedValues(value); }
}
public List<string> Value
{
get { return _value; }
set { _value = value; _Select(); }
}
private List<string> _value;
}
Now you can place your editor template in Views/Shared/MultiSelectModel.ascx...
<%# Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<WebUI.Cofamilies.Models.Shared.MultiSelectModel>" %>
<div class="set">
<%=Html.LabelFor(model => model)%>
<ul>
<% for (int i = 0; i < Model.Items.Count; i++)
{
var item = Model.Items[i];
string name = ViewData.ModelMetadata.PropertyName + ".Value[" + i + "]";
string id = ViewData.ModelMetadata.PropertyName + "_Value[" + i + "]";
string selected = item.Selected ? "checked=\"checked\"" : "";
%>
<li>
<input type="checkbox" name="<%= name %>" id="<%= id %>" <%= selected %> value="true" />
<label for="<%= id %>"><%= item.Text %></label>
<input type="hidden" name="<%= name %>" value="false" />
</li>
<% } %>
</ul>
<%= Html.ValidationMessageFor(model => model) %>
Two advantages to this approach:
You don't have to treat the list of items separate from the selection value. You can put attributes on the single property (e.g., AtLeastOneRequired is a custom attribute in our system)
you separate model and view (editor template). We have a horizontal and a vertical layout of checkboxes for example. You could also render "multiple selection" as two listboxes with back and forth buttons, multi-select list box, etc.
I think what you need is how gather selected values from CheckBoxList that user selected and here is my solution for that:
1- Download Jquery.json.js and add it to your view as reference:
2- I've added a ".cssMyClass" to all checkboxlist items so I grab the values by their css class:
<script type="text/javascript" >
$(document).ready(function () {
$("#btnSubmit").click(sendValues);
});
function populateValues()
{
var data = new Array();
$('.myCssClas').each(function () {
if ($(this).attr('checked')) {
var x = $(this).attr("value");
data.push(x);
}
});
return data;
}
function sendValues() {
var data = populateValues();
$.ajax({
type: 'POST',
url: '#Url.Content("~/Home/Save")',
data: $.json.encode(data),
dataType: 'json',
contentType: 'application/json; charset=utf-8',
success: function () { alert("1"); }
});
}
</script>
3- As you can see I've added all selected values to an Array and I've passed it to "Save" action of "Home" controller by ajax 4- in Controller you can receive the values by adding an array as argument:
[HttpPost]
public ActionResult Save(int[] val)
{
I've searched too much but apparently this is the only solution. Please let me know if you find a better solution for it.
when you have multiple items with the same name you will get their values separated with coma