TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Stanley Manoto
NA
2
594
{"Object reference not set to an instance of an object."}
Nov 15 2017 3:10 AM
My View
-----------
<div class="form-group">
@Html.LabelFor(model => model.PhysicalAddr, htmlAttributes: new { @class = "control-label", @style = "margin-left:10px; float:left;" })
<div>
@Html.EditorFor(model => model.PhysicalAddr, new { htmlAttributes = new { @class = "form-control", @style = "margin-left:150px;" } })
@Html.ValidationMessageFor(model => model.PhysicalAddr, "", new { @style = "color:red;!important; margin-left:150px;" })
</div>
</div>
model
--------------
public class PersonModel
{
public PersonModel()
{
marketService = new MarketModel();
//regionService = new RegionModel();
Region = new List<RegionModel>();
}
[Required]
[Display(Name = "Region")]
public int RegionId { get; set; }
public List<RegionModel> Region { get; set; }
}
Controller
-------------
public List<RegionModel> GetRegionList()
{
var list = regionService.GetRegions();
List<RegionModel> regionList = new List<RegionModel>();
int tableRow = Convert.ToInt32(list.Tables.Count);
for (int i = 0; i < tableRow; i++)
{
foreach (DataRow dr in list.Tables[i].Rows)
{
regionList.Add(new RegionModel
{
RegionId = Convert.ToInt32(dr["RegionId"]),
RegionName = Convert.ToString(dr["RegionName"]),
State = Convert.ToString(dr["State"]),
ZipCode = Convert.ToInt32(dr["ZipCode"])
});
}
}
return regionList;
}
Reply
Answers (
1
)
How to skip the installation using deployed setup fileVS2010
.net MVC 4 without using entity framework