ASP.NET
|
|
 |

|
I want to store the users ID from the previous drop down so it will update automatically if they try to create another holiday (to replace the second drop down)
Im using a session variable to do this, My View:
//this coverts the user ID to a string and stores it in session["usernameID"]
string userID = currentPersonID.ToString();
Session["usernameID"] = userID;
-------------------------------------------------
//My Create:
//catches the session["UsernameID"], stores it in string 'xx'
//converts it to an int and stores it in currentPersonID
//then store the value of currentpersonID in the model
public ActionResult Create()
{
string xx = (string)Session["usernameID"];
int? currentPersonID = Convert.ToInt32(xx);
HolidayList model = new HolidayList();
model.currentPersonID = currentPersonID.Value;
-------------------------------------------------
This all works fine, howeve how do I display the value properly in the view?
Where I was using :
@Html.DropDownListFor(model => model.PersonId, new SelectList(ViewBag.Id, "Value", "Text"),"---Select---")
i've tried:
@Html.TextBoxFor(model =>model.currentPersonID, "currentPersonID")
//and
@Html.LabelFor(model =>model.currentPersonID)
hoping the correct ID would display, but only the text 'currentPersonID is displayed
please advise, thanks again
|
|
|
|
 |
|
|
General
News
Suggestion
Question
Bug
Answer
Joke
Rant
Admin