Click here to Skip to main content
       

.NET Framework

 
QuestionOOPS concepts in c# Pinmember95003940022-Dec-12 17:09 
AnswerRe: OOPS concepts in c# PinmvpRichard MacCutchan2-Dec-12 21:43 
AnswerRe: OOPS concepts in c# PinmemberEddy Vluggen3-Dec-12 1:00 
GeneralRe: OOPS concepts in c# Pinmember95003940023-Dec-12 1:49 
GeneralRe: OOPS concepts in c# PinmemberEddy Vluggen3-Dec-12 3:17 
AnswerRe: OOPS concepts in c# PinprotectorPete O'Hanlon3-Dec-12 1:58 
GeneralRe: OOPS concepts in c# Pinmember95003940023-Dec-12 2:07 
GeneralRe: OOPS concepts in c# PinprotectorPete O'Hanlon3-Dec-12 2:10 
GeneralRe: OOPS concepts in c# PinmvpDave Kreskowiak3-Dec-12 2:22 
GeneralRe: OOPS concepts in c# PinprotectorPete O'Hanlon3-Dec-12 2:24 
GeneralRe: OOPS concepts in c# Pinmember95003940023-Dec-12 2:33 
QuestionTAPI3 Call Id ?? Pinmembertrashambishion30-Nov-12 11:17 
AnswerRe: TAPI3 Call Id ?? PinmemberEddy Vluggen30-Nov-12 23:45 
QuestionDrop down list value returns to ---select--- after page refresh PinmemberxnaLearner30-Nov-12 4:49 
Heys guys
 
So in my application the user will select a name from the drop down list, click 'view' and the corresponding values will display on page.
 
A hyperlink is then used to sort the list in ascending order. For this to happen the page refreshes and displays the new order of the list.
 
The value of the drop down list returns back to its original value of 'select' instead of remaining the name of the person selected.
 
My Model:
 
public class HolidayList
{
public List HList4DD { get; set; }
public List PList4DD { get; set; }
 
public int currentPersonID { get; set; }
public IEnumerable<SelectListItem> Categories { get; set; }
 
public HolidayList()
{
HList4DD = new List();
PList4DD = new List();
}
}
}
----------------------------------------
 
my controller:
 
[HttpPost]
public ViewResult Index(int HolidayDate)
{
var holidays = db.Holidays.Include("Person");
 
HolidayList model = new HolidayList();
 
model.currentPersonID = HolidayDate;
model.PList4DD = db.People.ToList();
model.Categories = holidays.Select(x => new SelectListItem
{
Value = x.Id.ToString(),
Text = x.Person.Name
}
);
 

int data = HolidayDate;
 
model.HList4DD = db.Holidays.Where(h => h.PersonId == HolidayDate).ToList();
 
return View(model);
 
}
 
[HttpGet]
public ViewResult Index(string sortOrder, int? currentPersonID)
{
var holidays = db.Holidays.Include("Person");

HolidayList model = new HolidayList();

//not null
if (currentPersonID.HasValue)
{
model.currentPersonID = currentPersonID.Value;
 
}
else
{
model.currentPersonID = 0;
}
 
model.PList4DD = db.People.ToList();
 
ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "date" : "";
var dates = from d in db.Holidays
where d.PersonId == currentPersonID.Value
select d;

switch (sortOrder)
{
case "date":
dates = dates.OrderBy(p => p.HolidayDate);
break;
}
 
model.HList4DD = dates.ToList();
 
return View(model);
}
-----------------------
 
my view
 
i've tried a number of different attempts here, the following code worked but has the drop list problem
 
@Html.DropDownListFor(model => model.HList4DD.First().HolidayDate,
new SelectList(Model.PList4DD, "Id", "Name"),
// Model.currentPersonID
"---Select---"
) *@
 

-----------
 
my attempts to resolve this are:
 
@* @Html.DropDownList("HolidayDate", Model.Categories, "---Select---")*@
 
@* @Html.DropDownListFor("HolidayDate", x => x.HolidayDate, Model.Categories)
*@
------------
 
Any help much appreciated
 
thaks
Questionimage processing Pinmembermarwamekky29-Nov-12 2:52 
AnswerRe: image processing PinmvpDave Kreskowiak30-Nov-12 4:12 
AnswerRe: image processing Pinmember@AmitGajjar2-Dec-12 5:04 
QuestionIIS Server access Pinmember950039400228-Nov-12 18:55 
AnswerRe: IIS Server access PinmemberEddy Vluggen30-Nov-12 23:48 
AnswerRe: IIS Server access Pinmember@AmitGajjar2-Dec-12 5:03 
GeneralRe: IIS Server access Pinmember95003940022-Dec-12 17:03 
AnswerRe: IIS Server access PinmemberAnkitGoel.com10-Dec-12 17:41 
QuestionSystem.Threading.Timer Class Pinmembersaswademayur27-Nov-12 23:40 
AnswerRe: System.Threading.Timer Class PinmvpDave Kreskowiak30-Nov-12 4:11 
GeneralRe: System.Threading.Timer Class Pinmembersaswademayur8-Apr-13 0:24 
QuestionAbout Collections in .NET PinmemberrathmA_27-Nov-12 18:57 
AnswerRe: About Collections in .NET PinprotectorPete O'Hanlon28-Nov-12 0:08 
GeneralRe: About Collections in .NET PinmemberrathmA_28-Nov-12 16:48 
GeneralRe: About Collections in .NET PinprotectorPete O'Hanlon28-Nov-12 21:57 
GeneralRe: About Collections in .NET PinmemberrathmA_6-Dec-12 17:22 
AnswerRe: About Collections in .NET PinmemberEddy Vluggen1-Dec-12 5:44 
Questionsuggestion Pinmembereeshwr23-Nov-12 3:29 
AnswerRe: suggestion PinmvpRichard MacCutchan23-Nov-12 5:26 
GeneralRe: suggestion Pinmembereeshwr23-Nov-12 5:39 
Questionprogramming Pinmembereeshwr23-Nov-12 3:24 
AnswerRe: programming PinmvpRichard MacCutchan23-Nov-12 5:26 
GeneralRe: programming Pinmembereeshwr23-Nov-12 5:38 
Questioncalculate average inside my ssrs 2008 Pinmembermenacy22-Nov-12 10:09 
AnswerRe: calculate average inside my ssrs 2008 PinmvpRichard MacCutchan22-Nov-12 23:35 
QuestionString compression PinmemberBlikkies19-Nov-12 21:03 
AnswerRe: String compression Pinmembern.podbielski19-Nov-12 21:15 
GeneralRe: String compression PinmemberBlikkies19-Nov-12 21:19 
JokeRe: String compression Pinmembern.podbielski19-Nov-12 21:22 
Questionestoy tratando de compilar un archivo.mex a .net [modified] Pinmemberyeyomax19-Nov-12 9:33 
AnswerRe: estoy tratando de compilar un archivo.mex a .net PinmemberEddy Vluggen19-Nov-12 11:09 
GeneralRe: estoy tratando de compilar un archivo.mex a .net PinmemberIdeasPravinh23-Nov-12 23:47 
AnswerRe: estoy tratando de compilar un archivo.mex a .net PinmemberBernhard Hiller19-Nov-12 22:35 
GeneralRe: estoy tratando de compilar un archivo.mex a .net Pinmemberyeyomax20-Nov-12 5:25 
GeneralRe: estoy tratando de compilar un archivo.mex a .net PinmvpDave Kreskowiak20-Nov-12 6:11 
Question[VB.NET 2008] Change form from separate thread (Windows CE) PinmemberMember 949661319-Nov-12 2:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 17 Apr 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid