Einfügen von Daten mit AJAX (ASP.NET MVC) in Datenbank ein.C#

Ein Treffpunkt für C#-Programmierer
Anonymous
 Einfügen von Daten mit AJAX (ASP.NET MVC) in Datenbank ein.

Post by Anonymous »

Ich habe Tabelle mit Frage 1 - Frage 10 < /p>

Hier ist die Tabellensyntax < /p>

CREATE TABLE [dbo].[QuestionBlocks] (
[Block_ID] INT IDENTITY (1, 1) NOT NULL,
[Question1] NVARCHAR (MAX) NULL,
[Question2] NVARCHAR (MAX) NULL,
[Question3] NVARCHAR (MAX) NULL,
[Question4] NVARCHAR (MAX) NULL,
[Question5] NVARCHAR (MAX) NULL,
[Question6] NVARCHAR (MAX) NULL,
[Question7] NVARCHAR (MAX) NULL,
[Question8] NVARCHAR (MAX) NULL,
[Question9] NVARCHAR (MAX) NULL,
[Question10] NVARCHAR (MAX) NULL,
< /code>

Außerdem habe ich Dropdownlisten für diese Fragen < /p>

Hier sieht es aus wie < /p>




Ich brauche auf der Schaltfläche Klicken Sie auf Daten von Dropdownlists und schreiben Sie Frage1- FRAGE10 Zeilen in der Datenbank.public ActionResult Index()
{
ViewBag.Question1 = new SelectList(db.Questions,"QuestionId","question");
ViewBag.Question2 = new SelectList(db.Questions, "QuestionId", "question");
ViewBag.Question3 = new SelectList(db.Questions, "QuestionId", "question");
ViewBag.Question4 = new SelectList(db.Questions, "QuestionId", "question");
ViewBag.Question5 = new SelectList(db.Questions, "QuestionId", "question");
ViewBag.Question6 = new SelectList(db.Questions, "QuestionId", "question");
ViewBag.Question7 = new SelectList(db.Questions, "QuestionId", "question");
ViewBag.Question8 = new SelectList(db.Questions, "QuestionId", "question");
ViewBag.Question9 = new SelectList(db.Questions, "QuestionId", "question");
ViewBag.Question10 = new SelectList(db.Questions, "QuestionId", "question");

return View(db.Questions.ToList());
}
< /code>

Und hier ist Ansicht < /p>


@Html.DropDownList("Question1", null, "Вопрос 1", htmlAttributes: new {@class = "form-control", @style = "height:40px;margin-bottom: 20px;",placeholder="lol"})
@Html.DropDownList("Question2", null, "Вопрос 2", htmlAttributes: new {@class = "form-control", @style = "height:40px; margin-bottom: 20px;"})
@Html.DropDownList("Question3", null, "Вопрос 3", htmlAttributes: new {@class = "form-control", @style = "height:40px; margin-bottom: 20px;"})
@Html.DropDownList("Question4", null, "Вопрос 4", htmlAttributes: new {@class = "form-control", @style = "height:40px; margin-bottom: 20px;"})
@Html.DropDownList("Question5", null, "Вопрос 5", htmlAttributes: new {@class = "form-control", @style = "height:40px; margin-bottom: 20px;"})
@Html.DropDownList("Question6", null, "Вопрос 6", htmlAttributes: new {@class = "form-control", @style = "height:40px; margin-bottom: 20px;"})
@Html.DropDownList("Question7", null, "Вопрос 7", htmlAttributes: new {@class = "form-control", @style = "height:40px; margin-bottom: 20px;"})
@Html.DropDownList("Question8", null, "Вопрос 8", htmlAttributes: new {@class = "form-control", @style = "height:40px; margin-bottom: 20px;"})
@Html.DropDownList("Question9", null, "Вопрос 9", htmlAttributes: new {@class = "form-control", @style = "height:40px; margin-bottom: 20px;"})
@Html.DropDownList("Question10", null, "Вопрос 10", htmlAttributes: new {@class = "form-control", @style = "height:40px; margin-bottom: 20px;"})

< /code>

Ich denke, Ajax kann dies tun, aber wie ich Code schreiben muss oder wo ich darüber schreiben kann, wie das geht? < /p>

Danke < /p>

Update < /strong> < /p>

Danke Prasanna Kumar J für die Antwort < /p>

Ich habe noch eine Frage < /p>

Ich schreibe eine Funktion und versuche sie durch Schaltfläche durchzuführen. Klicken Sie auf
Ich schreibe diesen Code in html < /p>


< /code>

und dies in js < /p>

$(document).ready(function () {
$('#save').click(function () {
save();
});
});
< /code>

Aber die Funktion wird nicht auf der Schaltfläche ausgeführt. Wo ist Fehler?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post