我在每一行都有一个带有和图标的asp.net gridview,当单击它时,我希望创建一个带有可编辑文本框/输入字段的弹出窗口。这些文本框和输入字段将包含行图标中的现有文本刚刚点击。
我以为我可以这样做,但是它从类中获取文本,而不是从 id 获取文本,请参见代码的底行:
$(".imgEditFields").click(function () {
var row = $(this).closest("tr");
var strServiceID = $(".clHiddenServiceID", row).text();
var strTitleOfDoc = $(document).attr('title');
var strSessionUser = strTitleOfDoc.replace("Order Tracking for ", "");
var strPSTNNumber = $(".clHiddenPSTNNum", row).text();
var strPSTNNum = strPSTNNumber.replace(/'/g, "");
$('#popupTrackerEditFields h1:first').text("Edit Record " + strPSTNNum);
var strSuppOrdNo = $("#lblSupplierOrderNum", row).text();
以下是我的评论,我尝试了你们所有人的评论/回复的几种形式
$(".imgEditFields").click(function () {
//I get the row with the icon that was clicked on
var row = $(this).closest("tr");
var strServiceID = $(".clHiddenServiceID", row).text();
var strTitleOfDoc = $(document).attr('title');
var strSessionUser = strTitleOfDoc.replace("Order Tracking for ", "");
var strPSTNNumber = $(".clHiddenPSTNNum", row).text();
var strPSTNNum = strPSTNNumber.replace(/'/g, "");
$('#PopUpTrackerEditFields h1:first').text("Edit Record " + strPSTNNum);
var strSuppOrdNo = $(".clSupplierOrderNumber", row).text();
//All the above work great and i get what is expected, the problem begins blow when trying to select by //the id (in that row)
//The below line achieves what i want visually but i cannot gaurantee its the correct row can i?
$('#MainContent_tbPopUpEditSuppOrdNo').val(strSuppOrdNo);
//The below line does not work as suggested by the replies and i have tried with HTML, val, Text etc
$('#<%=tbPopUpEditSuppOrdNo.ClientID%>', row).html(strSuppOrdNo);
//the blow works again not sure if it is selecting the correct row each time
$('#MainContent_tbPopUpEditSuppOrdNo').attr('title', 'Edit your Supplier no here for ' + strPSTNNum);