だからここに取引があります、私はExcelにアイテムの列挙可能なものをエクスポートできるようにしたいです:
これは、「ExportToExcel」モデルを構築し、それを別のコントローラーのアクションメソッドにリダイレクトするアプリの一部の領域のActionMethodであり、別のコントローラーは、すべての書式設定からExcelへの作業を実行します。
public ActionResult ExportCustomListToExcel()
{
var exportModel = new ExportToExcelModel();
//Here I fill up the model with a dataTable / other file info like
//exportModel.Items = blah blah..
return RedirectToAction("ExportToExcel", "Shared", new { model = exportModel, testString = "test", area = "Shared" });
}
そして、これが私のSharedExportToExcelActionMethodです。
public ActionResult ExportToExcel(ExportToExcelModel model, string testString)
{
//PROBLEM IS RIGHT HERE!
// where testString == "test"
// but model == null :(
//Ommited unrelated code
}
ExportToExcel actionMethodがヒットしましたが、途中でExportToExcelModelが失われました:(
注:「testString」のような文字列の受け渡しに成功するので、モデルに何か問題がありますか?
念のため、ExportToExcelModelは次のとおりです。
public class ExportToExcelModel
{
public ExportToExcelModel() {}
public ExportToExcelModel(string fileName, ItemType itemType, IEnumerable<ExportableToExcelItem> items)
{
this.FileName = fileName;
this.ItemType = ItemType;
this.Items = items;
}
public string FileName { get; set; }
public ItemType ItemType { get; set; }
public IEnumerable<ExportableToExcelItem> Items { get; set; }
}
前もって感謝します!
私が今までに見つけた他のすべての質問がすでにここで答えられているので、初めて私は実際にここで質問をする必要がありました:)
編集:FormCollectionの結果の投稿:
http://imageshack.us/photo/my-images/861/sinttulonsa.png 申し訳ありませんが、初心者は写真を投稿できません:(