Click here to Skip to main content
15,895,772 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have a .Net application that I am trying to finish putting together. I have a form that I want to submit that is very similar to this one:

http://www.binaryintellect.net/articles/b1e0b153-47f4-4b29-8583-958aa22d9284.aspx[^]

The only difference in mine is that I don't want all of my fields text boxes. Some of them I just want to display as plain text so that the user can't edit them. Here is some of the code that I am using:

C#
@using (Html.BeginForm("save", "drnos", FormMethod.Post))
   {

       for (int i = 0; i < Model.Count; i++)
       {
           <tr>
               <td>
                   @Html.DisplayFor("drnos[" + @i + "].RVH_ID_", Model[i].RVH_ID_)
               </td>
               <td>
                   @Html.DisplayFor("drnos[" + @i + "].Last_Name", Model[i].Last_Name)
               </td>
               <td>
                   @Html.CheckBoxFor("drnos[" + @i + "].Orsos", Model[i].Orsos)

               </td>
                <td>
                   @Html.TextBox("drnos[" + @i + "].Group", Model[i].Group)
               </td>


My issue is that when I have the DisplayFor on there, it gives out the error message: The type of arguments for method cannot be inferred from the usage. Try specifying the type arguments explicitly.

I am confused on why it works fine with the TextBoxes, but not for DisplayFor or CheckBoxFor. Any help would be appreciated!
Posted
Updated 28-May-15 2:24am
v2

1 solution

Just write the data direct to the page

<td>
    @Model[i].Last_Name
</td>
 
Share this answer
 
Comments
britbarnes 28-May-15 10:10am    
Wow, that was simple. Thank you so much!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900