15,907,001 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
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)
@Model.Id
And the result:
<input id="Changes_0__Id" name="Changes[0].Id" type="hidden" value="7617" />
7618
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)
{
counter++;
@Html.Hidden("[" + counter + "].Id", item.Id)
<li>@item.Id</li>
}
Result:
<input name="[1].Id" type="hidden" value="7616" /> <li>7617</li>
Code:
@foreach(var item in Model)
{
counter++;
@Html.HiddenFor(m => item.Id)
<li>@item.Id</li>
}
Result:
<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; }
AnalogNerd
6-Jun-13 12:46pm
View
I actually had it as a foreach before and the same thing happens.
I did confirm that the Model being return from the action is correct, but for some reason this old Id is hanging out in the View.
AnalogNerd
6-Jun-13 12:42pm
View
MemberId is different from the ID. The MemberId is their actual membership number, the Id is the primary key in the database (a member could be in this table multiple times, so MemberId couldn't be used as a primary key).
The problem is this line :
@Html.HiddenFor(m => Model[i].Id)
and this code:
data-billpayid="@Model[i].Id"
Return two different numbers in the code. The latter is correct, the HiddenFor code shows the old Id from the previous items.
AnalogNerd
13-Dec-12 16:32pm
View
Thanks, that worked like a charm. The link was really useful as I have never done anything with IComparer before.
AnalogNerd
10-Dec-12 11:21am
View
I have not tried your code myself, but that should work, yes.
AnalogNerd
5-Dec-12 15:03pm
View
Saying "it doesn't work" is too vague to provide you any useful information. What error are you getting? Show the error, or your code.
AnalogNerd
30-Nov-12 11:50am
View
Deleted
I don't think this will solve your problem, but as a general thought you should not use "ctl00_ContentPlaceHolder1_ChkAssignPages"
The Id could conceivably change on you, to be safe you should do something like
var chkBoxList1= document.getElementById("<%= ChkAssignPages.ClientID");
This will let .NET put the real client ID in there for you each time.
Show More