UFO Disko 0 Newbie Poster


I just created a basic app that fetches records from a db with an edit page.

I understand that my code is a bit messed up and would like it if you could tell me where did I go wrong with it.

This is my code for EditArticles.cshtml

    Layout = "../Shared/_AdminPanelLayout.cshtml";
<div class="right_content">            
    <h2>Add Article</h2> 
         <div class="form">
         <form action="" method="post" class="niceform">
	var id = Request["id"];
	var SQLSELECT = "SELECT * FROM Articles where ArticleID=@0";
	var db = Database.Open("ContosoKaratePRM");
	var Article = db.QuerySingle(SQLSELECT, id);
	var Title = Article.ArticleTitle;
	var Body = Article.ArticleBody;
	var Date = Article.ArticleDate;
	var User = Article.UserID;

			Title = Request["formTitle"];
			Body = Request["formBody"];
			Date = DateTime.Now;
			User = Request["formAuthorID"];
			var SQLUPDATE = "UPDATE Articles SET ArticleTitle=@0, ArticleBody=@1, ArticleDate=@2, UserID=@3 WHERE id=@4";
			db.Execute(SQLUPDATE, Title, Body, Date, User, id);
        else {
                        <dt><label for="Title">Article Title</label></dt>
                        <dd><input type="text" name="formTitle" id="" size="54" value="@Title" /></dd>
                        <dt><label for="gender">Select Author:</label></dt>
                                <select size="1" name="formAuthorID" id="">
                                <option value="@User">@User</option>
                        <dt><label for="comments">Article Body:</label></dt>
                        <dd><textarea name="formBody" id="comments" rows="25" cols="45">@Body</textarea></dd>
                     <dl class="submit">
                    <input type="submit" name="submit" id="submit" value="Submit" />
     </div><!-- end of right content-->

What I wanna do here is display all the users in the dropdown menu found in table UserProfile and display the correct author of that article on that dropdown menu.

How can I do that?

These are my tables and fields:
- Articles


Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.