Click here to Skip to main content
12,950,272 members (65,772 online)

.NET Framework

 
GeneralRe: OOPS concepts in c# Pin
95003940023-Dec-12 2:07
member95003940023-Dec-12 2:07 
GeneralRe: OOPS concepts in c# Pin
Pete O'Hanlon3-Dec-12 2:10
protectorPete O'Hanlon3-Dec-12 2:10 
GeneralRe: OOPS concepts in c# Pin
Dave Kreskowiak3-Dec-12 2:22
mvpDave Kreskowiak3-Dec-12 2:22 
GeneralRe: OOPS concepts in c# Pin
Pete O'Hanlon3-Dec-12 2:24
protectorPete O'Hanlon3-Dec-12 2:24 
GeneralRe: OOPS concepts in c# Pin
95003940023-Dec-12 2:33
member95003940023-Dec-12 2:33 
QuestionTAPI3 Call Id ?? Pin
trashambishion30-Nov-12 11:17
membertrashambishion30-Nov-12 11:17 
AnswerRe: TAPI3 Call Id ?? Pin
Eddy Vluggen30-Nov-12 23:45
memberEddy Vluggen30-Nov-12 23:45 
QuestionDrop down list value returns to ---select--- after page refresh Pin
xnaLearner30-Nov-12 4:49
memberxnaLearner30-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<holiday> HList4DD { get; set; }
public List<person> PList4DD { get; set; }

public int currentPersonID { get; set; }
public IEnumerable<SelectListItem> Categories { get; set; }

public HolidayList()
{
HList4DD = new List<holiday>();
PList4DD = new List<person>();
}
}
}
----------------------------------------

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 Pin
marwamekky29-Nov-12 2:52
membermarwamekky29-Nov-12 2:52 
AnswerRe: image processing Pin
Dave Kreskowiak30-Nov-12 4:12
mvpDave Kreskowiak30-Nov-12 4:12 
AnswerRe: image processing Pin
@AmitGajjar2-Dec-12 5:04
member@AmitGajjar2-Dec-12 5:04 
QuestionIIS Server access Pin
950039400228-Nov-12 18:55
member950039400228-Nov-12 18:55 
AnswerRe: IIS Server access Pin
Eddy Vluggen30-Nov-12 23:48
memberEddy Vluggen30-Nov-12 23:48 
AnswerRe: IIS Server access Pin
@AmitGajjar2-Dec-12 5:03
member@AmitGajjar2-Dec-12 5:03 
GeneralRe: IIS Server access Pin
95003940022-Dec-12 17:03
member95003940022-Dec-12 17:03 
AnswerRe: IIS Server access Pin
AnkitGoel.com10-Dec-12 17:41
memberAnkitGoel.com10-Dec-12 17:41 
QuestionSystem.Threading.Timer Class Pin
saswademayur27-Nov-12 23:40
membersaswademayur27-Nov-12 23:40 
AnswerRe: System.Threading.Timer Class Pin
Dave Kreskowiak30-Nov-12 4:11
mvpDave Kreskowiak30-Nov-12 4:11 
GeneralRe: System.Threading.Timer Class Pin
saswademayur8-Apr-13 0:24
membersaswademayur8-Apr-13 0:24 
QuestionAbout Collections in .NET Pin
rathmA_27-Nov-12 18:57
memberrathmA_27-Nov-12 18:57 
AnswerRe: About Collections in .NET Pin
Pete O'Hanlon28-Nov-12 0:08
protectorPete O'Hanlon28-Nov-12 0:08 
GeneralRe: About Collections in .NET Pin
rathmA_28-Nov-12 16:48
memberrathmA_28-Nov-12 16:48 
GeneralRe: About Collections in .NET Pin
Pete O'Hanlon28-Nov-12 21:57
protectorPete O'Hanlon28-Nov-12 21:57 
GeneralRe: About Collections in .NET Pin
rathmA_6-Dec-12 17:22
memberrathmA_6-Dec-12 17:22 
AnswerRe: About Collections in .NET Pin
Eddy Vluggen1-Dec-12 5:44
memberEddy Vluggen1-Dec-12 5:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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
Web02 | 2.8.170525.1 | Last Updated 25 May 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid