Click here to Skip to main content
15,506,209 members

Comments by AnalogNerd (Top 11 by date)

AnalogNerd 4-Feb-15 13:46pm View    
You're absolutely correct, I missed that. Good catch.

ExecuteScalar would have to be run first into an object, and then you could check that object for DbNull.Value. If it isn't null, conver to an integer.

Basically, Pete's answer above is what I was going for (but didn't quite make it).
AnalogNerd 31-Mar-14 9:29am View    
What version of unity are you using?
AnalogNerd 6-Jun-13 14:07pm View    
My problem with a foreach is that it was not returning my model to the action when I posted. This may have been because my model for the view was a typed List. I created a new viewmodel that has a list in it of my queues. I then did a foreach, same thing.

I then did a EditorTemplate, here's the new code in my view:
@Html.EditorFor(m => m.Changes)

and in the template:
@Html.HiddenFor(m => Model.Id)

And the result:
<input id="Changes_0__Id" name="Changes[0].Id" type="hidden" value="7617" />
AnalogNerd 6-Jun-13 13:32pm View    
I changed it to a foreach, and while this might not be the correct way to do this, the result was interesting.

@foreach(var item in Model)
@Html.Hidden("[" + counter + "].Id", item.Id)

<input name="[1].Id" type="hidden" value="7616" /> <li>7617</li>

@foreach(var item in Model)
@Html.HiddenFor(m => item.Id)

<input id="item_Id" name="item.Id" type="hidden" value="7617" /> <li>7617</li

AnalogNerd 6-Jun-13 13:00pm View    
My getter doesn't do anything:

public int Id { get; set; }