私はMVC3の新機能であり、一般的な方向性が必要だと言うことから始めます。何らかの操作の後にページにコントロールを追加するMVC3
私は現在、DevExpressアップロードコントロール付きのMVC3ウェブページを持っています。アップロードコントロールは、選択したドキュメントを解析し、ファイルから取得したデータでWebサービスを呼び出します。私はデビューエクスプレスグリッド(私は部分的な見方があります)にWebサービスの応答を表示したいのですが、Webサービスからの結果が受信されるまでそれをインスタンス化する方法を理解することはできません。ここで
は、私がこれまで持っているものだ...
Index.cshtml
<div id="form" style="float:left; margin-left:50px;">
<p>Select a file to upload:</p>
@using (Html.BeginForm("Index", "StepUpdater", FormMethod.Post, new { id="uploadForm", name="uploadForm" }))
{
@Html.DevExpress().UploadControl(settings =>
{
settings.Name = "uploadController";
settings.Width = 325;
settings.CallbackRouteValues = new { Controller = "StepUpdater", Action = "CallbacksUpload" };
settings.UploadButton.
}).GetHtml()
<label style="color:Red">@TempData["Error"]</label>
@Html.DevExpress().Button(settings =>
{
settings.Name = "uploadButton";
settings.Text = " Upload";
settings.UseSubmitBehavior = false;
settings.ClientSideEvents.Click = "function(s,e){uploadController.Upload();}";
}).GetHtml()
}
<br />
@Html.Partial("GridViewPartial", (IEnumerable<StepResponse>)Model)
GridViewPartial.cshtml
@using DevExpress.Web.Mvc.UI
@using DevExpress.Web.Mvc
@Html.DevExpress().GridView(settings => {
settings.Name = "Responses";
settings.CallbackRouteValues = new { Controller = "StepUpdater", Action = "GridViewPartial" };
settings.Settings.ShowColumnHeaders = true;
settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
}).Bind(Model).GetHtml()
コントローラ
private IEnumerable<StepResponse> responses = new List<StepResponse>();
public IEnumerable<StepResponse> Responses
{
get { return responses; }
set { responses = value; }
}
public ActionResult Index()
{
return View(Responses);
}
public ActionResult GridViewPartial()
{
if (Responses == null)
Responses = new List<StepResponse>();
return PartialView("GridViewPartial", Responses);
}
public ActionResult CallbacksUpload()
{
UploadControlExtension.GetUploadedFiles("uploadController", new ValidationSettings { AllowedFileExtensions = new []{ ".csv" }}, uploadControl_FileUploadCompleted);
return GridViewPartial();
}
.... steps to parse csv and put results in Responses object