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
Sagar Bandkar
NA
347
49.1k
View ListBoxFor healper data from Grid in MVC
Dec 24 2016 2:31 AM
I want to view data in listbox after click on view button in Grid.other value got except ListBox value,
View:-
<div class="form-group col-xs-6 col-sm-6">
@Html.ListBoxFor(x => x.SelectedNames, Model.Names, new { Size = 20, style = "width:190%;" })
</div>
<div class="form-group col-xs-6 col-sm-6">
@Html.ListBoxFor(model => model.SelectedNames, new MultiSelectList("",Model.SelectedNames), new { Size = 20, style = "width:190%;" })
</div>
Controller:-
public ShiftNameViewModel ViewPatternById(int inPtnId)
{
try
{
if (inPtnId > 0)
{
tblMstPattern_PTN PatternDetail = db.tblMstPattern_PTN.Find(inPtnId);
tblTxnPatternData_PTD_T txnPatternDetail = db.tblTxnPatternData_PTD_T.Find(inPtnId);
var patternValue = new ShiftNameViewModel()
{
inPtnId = PatternDetail.inPtnId,
vcPtnCode = PatternDetail.vcPtnCode,
vcPtnName = PatternDetail.vcPtnName,
SelectedNames = PatternDetail.vcPtnData.Split(new char[] { ',' }).ToList()
};
return patternValue;
}
}
catch (Exception ex) { ex.Message.ToString(); }
return null;
}
In viewModel :
public IEnumerable<SelectListItem> Names { get; set; }
public IEnumerable<string> SelectedNames { get; set; }
Reply
Answers (
2
)
How to implement site map path in asp.net ??
How to cascade 4 dropdownlist from same one table in mvc