我如何从下面的列表视图中单击按钮时选择val(),

时间:2019-03-17 04:16:15

标签: jquery asp.net-mvc

此处是CRUD TYPE LIST IEnumerable WorkingPlace.Models.PerchesDetail

当列表显示在屏幕上并且我单击按钮时,我需要所有字段值, 但是我无法获得很多尝试,

html

def main():   
    print("Roses are", colors[],".")   
    print("Violet are",color[],".")   
    print("The weather may", verb[],".")   
    print("But I will always", verb[],"you.") 
main()

这里我需要所有物品。通过使用jQuery元素值

                    @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>

这是不同类型的尝试,但我可以设定该值

需要帮助

1 个答案:

答案 0 :(得分:0)

DisplayFor不能具有ID,请参见this link供参考。

因此请向您的外部HTML标记提供ID,然后使用ID进行访问。 例如:
在HTML中:

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

在JQuery中,您可以使用:

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