You must Sign In to post a response.
  • Category: ASP.Net MVC

    Display Error in view for records from datacolumn


    following is a working code that displays record in view using datacolumn and datarow

    @foreach (DataColumn col in Model.Columns)
    @foreach (DataRow row in Model.Rows)
    @foreach (DataColumn col in Model.Columns)

    <td> @Html.ActionLink("Edit", "Edit") |</td>

    my problem is i can't add an in edit this example first column of every row contains id .

    i want to add id to edit field like this

    <td> @Html.ActionLink("Edit", "Edit"), new { id=col[0] } |</td>

    i tried it several times ,yet to succeed.


  • #751274
    Hello baiju,

    Have you debug that you have an id in col[0] column?
    If yes, than try this.

    @Html.ActionLink("Edit", "Edit", new { id=row[0] })

    I hope this will help you,
    If you still have an issue regarding that than i'll get back to you.

    Nirav Prabtani (Senior Web Developer)
    Email :
    blog :

  • #751283
    use ViewBag to store error and on form

    using (Html.BeginForm("form_edit", "Form", FormMethod.Post))
    @Html.DisplayNameFor(model => model.content_name)
    @Html.DropDownListFor(show content from datatable columns)

    Hope it helps

    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #751326
    You have to add

    @Html.ActionLink("Update", "Edit", new { id = @row[ID] })

    Hope it will help

  • Sign In to post your comments