0

here a CRUD TYPE LIST IEnumerable WorkingPlace.Models.PerchesDetail

when the list is on screen and i click on button i need all fields value , but lots of try i cant get ,

html

                    @foreach (var item in Model)
                    {
                        <tr style="background-color:#eff6de">
                            <td class="hfr">
                                @Html.HiddenFor(modelItem => item.PerTranChallanId, new { @class = "PerTranChallanId" })
                                @Html.HiddenFor(modelItem => item.PTranCode, new { @class = "PTranCode" })
                            </td>
                            <td>
                                @Html.DisplayFor(modelItem => item.SypplyerName ,new {@class="sn", @id = "SypplyerName" })
                            </td>
                            <td>
                                @Html.DisplayFor(modelItem => item.ChallaNo)
                            </td>
                            <td>
                                @Html.DisplayFor(modelItem => item.ChallaDate)
                            </td>
                            <td>
                                @Html.DisplayFor(modelItem => item.TaxAmount)
                            </td>
                            <td>
                                @Html.DisplayFor(modelItem => item.TotalAmount)
                            </td>
                            <td>
                                @Html.ActionLink("Details", "Showchl1", new { id = item.PerTranChallanId , PTranCode=item.PTranCode }) |
                            </td>
                            <td class="con">
                                <input type="submit" id="convt" name="convt" value="Add To INv No:- @ViewBag.NewINVNo1" class="convt btn btn-success " />
                            </td>
                            <td class="csl">
                                <input type="submit" id="cansel" name="cancel" value="Cancel From INv No:- @ViewBag.NewINVNo1" class="convt btn btn-danger " />
                            </td>
                        </tr>
                    }
                </table>


            </div>

here i need all item. element value by using jquery

    $(document).on('click', '.convt', function () {

            alert("OK");
            var spn = $(this).prop("#SypplyerName").text();
           //var spn =$(this).prop("#SypplyerName").val();
            var aaa = $(this).closest("tr").html("#SypplyerName").val();


            spn1 = $(this).prop(".sn").val();
            //spn1=$(this).prop(".sn").text();
            aaa1 = $(this).closest("tr").html(".sn")val();
            //aaa1 = $(this).closest("tr").html(".sn").text();
            var nnn = $(".sn").text();

            alert(spn);
            alert(aaa);
            alert(spn1);
            alert(aaa1);
            alert(nnn);
        });

this is try of different type but i can gate this value

need help

yogesh vaidya
  • 21
  • 1
  • 1
  • 6

1 Answers1

0

DisplayFor can not have id, see this link for your reference.

So provide id to your outer HTML tag, and access using id. ex:
In HTML:

  <td id="sypplyerName">
        @Html.DisplayFor(modelItem => item.SypplyerName)
    </td>

In JQuery you can access the same using:

var sName=$('#sypplyerName').text();