So bin ich ein bisschen fest. Ich lerne immer noch all diese Sachen, aber ich musste meiner Anwendung einen CSV-Parser hinzufügen, der die Ergebnisse auf der Seite "Meine Warnungen" anzeigen sollte. Wenn ich es tuePartialView(); Der Name existiert nicht im aktuellen Kontext
Es wird mir sagen, Pin, tDate und stat existiert nicht im aktuellen Kontext. Wenn ich sie herausnehme, wird die App ausgeführt, aber das beabsichtigte Ergebnis wird nicht angezeigt.
Ich erklärte Stift, TDate und stat in dem UserADInfoModel.cs
hier ist die Steuerung:
public ActionResult _Alerts(UserADInfoModel model, List<string> groups)
{
DataRowCollection drColl = Core.GetAlerts(model);
ViewBag.Alerts = drColl;
var path = @"Exchange Migration data 10-25-17.csv";
using (TextFieldParser csvParser = new TextFieldParser(path))
{
csvParser.CommentTokens = new string[] { "#" };
csvParser.SetDelimiters(new string[] { "," });
csvParser.HasFieldsEnclosedInQuotes = true;
// Skip the row with the column names
csvParser.ReadLine();
// Read the lines
while (!csvParser.EndOfData)
{
string[] fields = csvParser.ReadFields();
string pin = fields[0];
string tDate = fields[2];
string stat = fields[6];
}
}
return PartialView(model, pin, tDate, stat);
}
und hier ist die Ansicht
@if (@ViewBag.pin == Model.SAM)
{
<tr style="background-color : #ff3333; color: #ffffff">
<td style="padding-left :10px; padding-right: 10px;padding-top:2px; padding-bottom: 2px">
<p>Critical</p>
</td>
<td style="padding-left :10px; padding-right: 10px;padding-top:2px; padding-bottom: 2px">
<p>Exchange Migration</p>
</td>
<td style="padding-left :10px; padding-right: 10px;padding-top:2px; padding-bottom: 2px">
<p>Caller was set to migrate on (@ViewBag.tDate). The status of the migration is (@ViewBag.stat). Please contact Hypercare</p>
</td>
</tr>
}
@foreach (var x in ViewBag.Alerts)
{
var uClass = (x["Weight"].Contains("Warning")) ? "#ff8c1a, " : (x["Weight"].Contains("Critical")) ? "#ff3333" : "";
<tr @if (x["Weight"].Contains("Warning")) {
@MvcHtmlString.Create("style=\"background-color: #ff8c1a\"")
}
else if(x["Weight"].Contains("Critical")){
@MvcHtmlString.Create("style=\"background-color: #ff3333; color: #ffffff\"")
}>
, was mache ich falsch? TIA
das tat und jetzt kehre ich bekommen PartialView (Modell, Stift, tDate, stat); Keine Überladung für die Methode PartialView dauert 4 Argumente – Melaa
Danke, das hat funktioniert! Keine Fehler zumindest, es zeigt immer noch nicht die Informationen, so muss ich irgendwo anders ein Problem haben. – Melaa
Möglicherweise haben Sie 'Model.SAM' nicht zugewiesen. – aaron