ViewDataDictionary传入Model

时间:2011-02-10 20:58:16

标签: .net asp.net-mvc-2 partial-views

using (var writer = new StringWriter())
                        {
                            viewPath += (viewName + ".aspx");
                            var view = new WebFormView(viewPath);
                            var vdd = new ViewDataDictionary<T>(indication.Model);
                            var viewCxt = new ViewContext(ControllerContext, view, vdd, new TempDataDictionary(), writer);
                            viewCxt.View.Render(viewCxt, writer);
                            return Json(
                                new { 
                                    html = writer.ToString()
                                    });
                        }

错误是:

Error   66  The best overloaded method match for 'System.Web.Mvc.ViewDataDictionary<T>.ViewDataDictionary(T)' has some invalid arguments    C:\SVN\k2\AppTeamTrunk\web\Chatham.Web\Controllers\IndicationsController.cs 318 39  Chatham.Web

我不确定如何让视图渲染模型中的传递。

任何帮助?

1 个答案:

答案 0 :(得分:0)

我认为你不需要这一行的<T>参数

var vdd = new ViewDataDictionary<T>(indication.Model);