Javascript 在jQuery中单击按钮时,有没有解决Asp.NETGridView行数据传输到某些特定文本框的解决方案?
我正在使用一个网格视图,当用户单击特定按钮或元素时,该视图将弹出数据。在弹出式网格视图的每一行中都有一个名为“Action”的列,该列由一个“Select Button”组成。当用户单击特定行上的选择按钮时,该行的数据将显示在某些特定文本框中。但问题是有些行工作正常,但大多数行显示“未找到数据”。我在这里使用了j-Query 这是gridView:Javascript 在jQuery中单击按钮时,有没有解决Asp.NETGridView行数据传输到某些特定文本框的解决方案?,javascript,c#,jquery,asp.net,Javascript,C#,Jquery,Asp.net,我正在使用一个网格视图,当用户单击特定按钮或元素时,该视图将弹出数据。在弹出式网格视图的每一行中都有一个名为“Action”的列,该列由一个“Select Button”组成。当用户单击特定行上的选择按钮时,该行的数据将显示在某些特定文本框中。但问题是有些行工作正常,但大多数行显示“未找到数据”。我在这里使用了j-Query 这是gridView: <asp:GridView ID="showAllProductsGridView" runat="server" A
<asp:GridView ID="showAllProductsGridView" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="ProductName" HeaderText="Product Name" SortExpression="ProductName" />
<asp:BoundField DataField="CategoryName" HeaderText="Category" SortExpression="CategoryName" />
<asp:BoundField DataField="SubCategoryName" HeaderText="SubCategory" SortExpression="SubCategoryName" />
<asp:BoundField DataField="Barcode" HeaderText="Barcode" SortExpression="Barcode" />
<asp:BoundField DataField="Cost" HeaderText="Cost" SortExpression="Cost" />
<asp:BoundField DataField="ProductId" HeaderText="ProductId" SortExpression="ProductId" Visible="False" />
<asp:BoundField DataField="CategoryId" HeaderText="CategoryId" SortExpression="CategoryId" Visible="False" />
<asp:BoundField DataField="SubCategoryId" HeaderText="SubCategoryId" SortExpression="SubCategoryId" Visible="False" />
<asp:BoundField DataField="SalesPrice" HeaderText="Sales Price" SortExpression="SalesPrice" />
<asp:TemplateField HeaderText="Action">
<ItemTemplate>
<asp:LinkButton ID="itemSelect" runat="server" Text="Select" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
基于ids和classnames等来选择
aspx标记非常困难,因为它们是服务器端的,大多数属性都会动态变化
有效且简单的方法是定义输入字段(run=“server”)
意味着它必须是aspx:input
Next defineonclick
,即使是在gridview
的每一行上。在该方法中,获取行的所需文本并更新为输入文本字段
这样,您就不需要在jquery
end上进行复杂的黑客操作
$('body').on("click", "#ctl00_ViewContentPlace_btnItemSearch", function () {
$('#main_div_item_search').delay().fadeIn();
});
$("#kv_close_item_search").click(function () {
$('#main_div_item_search').fadeOut();
});
$('#ctl00_ViewContentPlace_showAllProductsGridView').find('[id*=itemSelect]').click(function () {
var row = $(this).closest('tr');
$('#main_div_item_search').fadeOut();
$("#ctl00_ViewContentPlace_txtBarcode").val(row.find('td').eq(3).html());
$("#ctl00_ViewContentPlace_ddlCategory").val(row.find('td').eq(6).html());
$('#ctl00_ViewContentPlace_ddlSubcategory').val(row.find('td').eq(7).html());
$('#ctl00_ViewContentPlace_ddlProduct').val(row.find('td').eq(5).html());
});