Reputation: 11
I am trying to post a two values using razer views and mvc as a tuple.
I have tried all different formatting, separating, the values by commas, by putting parenthesis and brackets angle brackets.
<div class="location-input">
<input id="ElectionJsonObject.LocationPerVotingTypeDictionary[@item.Key] [@i]" type="checkbox" name="ElectionJsonObject.LocationPerVotingTypeDictionary[@item.Key][@item.Value.ElementAt(i).Key]" value="<(@item.Value.ElementAt(i).Value.Item1.ToString(), @item.Value.ElementAt(i).Value.Item2>" checked />
<input type="hidden" name="ElectionJsonObject.LocationPerVotingTypeDictionary[@item.Key][@item.Value.ElementAt(i).Key]" value="False" />
@Model.ElectionJsonObject.LocationPerVotingTypeDictionary[@item.Key].ElementAt(i).Key - @item.Value.ElementAt(i).Value.Item2
</div>
The model comes back with a null value tuple inside of that dictionary.
Upvotes: 0
Views: 538
Reputation: 11
As per Matheus Lemos comment I used a class instead.
public class LocationInformation
{
public string LocationDetails { get; set; }
public bool Display { get; set; }
//For data transfer
public LocationInformation()
{
}
This is the class.
<input id="ElectionJsonObject.LocationPerBallotTypeDictionary[@ballotType][@locationId]" type="checkbox" name="ElectionJsonObject.LocationPerBallotTypeDictionary[@ballotType][@locationId].Display" value="@locationInfo.Display.ToString()" checked />
<input type="hidden" name="ElectionJsonObject.LocationPerBallotTypeDictionary[@ballotType][@locationId].LocationDetails" value="@locationInfo.LocationDetails"/>
By changing the the name to be the class values property and the value to be a single value then adding a hidden input being the other value it properly posts and the model is intact dictionary values and all.
Upvotes: 1