2017-02-17 73 views
0

我試圖將隱藏值添加到我的WebGrid中,所以甚至沒有顯示列。雖然Html.Hidden的部分工作得很好,但列仍在顯示。有什麼建議麼?WebGrid中的隱藏列(ASP.Net)

WebGrid

WebGrid grid1 = new WebGrid(Model.StamfordRel, canPage: false, fieldNamePrefix: "g1", pageFieldName: "p1");  

     @grid1.GetHtml(
      headerStyle: "wg_header", 
      columns: new[] { 

      grid1.Column("logNo", 
       header: null, 
       format: (item) => Html.Hidden("logNo", (object)item.logNo), 
       style: "width"), 

      grid1.Column("instanceNo", 
       header: null, 
       format: (item) => Html.Hidden("instanceNo", (object)item.instanceNo), 
       style: "width_logNo"), 
     }) 

回答

1

嘗試使用設置與HTML:

grid1.Column("logNo", 
     header: null, 
     format: @<input type="hidden" name="logNo" value="@item.logNo"/> 
     style: "width"),