我有一个隐藏了几列的gridview。 当我将鼠标悬停在网格上的每一行上时,我希望隐藏的列值显示在gridview下面的文本框中。asp.net获取带有jQuery的gridview值并放在文本框中
以下是html/aspx代码(缩写) 只有几列可见,大多数是隐藏的。
<asp:GridView ID="GridView1" >
<rowstyle cssclass="GridRowStyle" />
<Columns>
<asp:BoundField DataField="ClientsName" HeaderText="ClientsName"></asp:BoundField>
<asp:BoundField DataField="Clientsaddress1" HeaderText="Clientsaddress1"><ItemStyle CssClass="hiddencol" /><HeaderStyle CssClass="hiddencol" /> </asp:BoundField>
<asp:BoundField DataField="Clientsaddress2" HeaderText="Clientsaddress3"><ItemStyle CssClass="hiddencol" /><HeaderStyle CssClass="hiddencol" /> </asp:BoundField>
</columns>
</asp:gridview>
<asp:TextBox ID="txtAddress1" runat="server" Width="250px" ></asp:TextBox>
<asp:TextBox ID="txtAddress2" runat="server" Width="250px" ></asp:TextBox>
下面是一些我使用来获取gridview的行,我选择了jQuery代码,但我不能让它给我的每个隐藏的列的值在GridView上一行。我已经尝试了几个在stackoverflow中找到的代码片段,但无法让它工作。 该代码给了我所在的行号,很棒,但无法获取隐藏列值,并将它们置于gridview下方的各自文本框中。
$("#GridView1 tr td").mouseenter(function() {
var iColIndex = $(this).closest("tr td").prevAll("tr td").length;
var iRowIndex = $(this).closest("tr").prevAll("tr").length;
alert(iRowIndex)
});
您的指导表示赞赏。
更新: 这里是一个什么样的HTML呈现。 该页面有大约600行文字,因此我缩短了仅显示gridview渲染的一个示例。
<tr title="Click to select this row." class="GridRowStyle" onclick="javascript:__doPostBack('GridView1','Select$0')">
<td class="hiddencol">23644</td>
<td class="hiddencol">10102</td>
<td class="hiddencol">Y</td>
<td class="hiddencol">21 Jump Street</td>
<td class="hiddencol">Sydney, Australia</td>
<td class="hiddencol"> </td>
<td>
<table>
<tr>
<td class="STD_normal" style="width:150px; font-weight:bold">Apple Inc.</td>
</tr>
<tr>
<td class="STD_Normal_Grey" style="width:150px">Entered: 31-Jan-2015 </td>
</tr>
</table>
</td><td>
<tr title="Click to select this row." class="GridRowStyle" onclick="javascript:__doPostBack('GridView1','Select$0')">
<td class="hiddencol">23644</td>
<td class="hiddencol">10102</td>
<td class="hiddencol">Y</td>
<td class="hiddencol">21 Jump Street</td>
<td class="hiddencol">Sydney, Australia</td>
<td class="hiddencol"> </td>
<td>
<table>
<tr>
<td class="STD_normal" style="width:150px; font-weight:bold">Apple Inc.</td>
</tr>
<tr>
<td class="STD_Normal_Grey" style="width:150px">Entered: 31-Jan-2015 </td>
</tr>
</table>
</td><td>
,如果你发布渲染HTML这将是很容易解决的问题。 – 2015-02-12 08:23:19
嗨,我已经发布了gridview区域的一些呈现的HTML ......我希望这就够了......谢谢。 – user1135218 2015-02-12 08:35:55
我会在html和jquery中发布下面的答案。 – 2015-02-12 08:37:15