我有一个HTML表格,其中包含我想要选择行的项目列表,并在不使用gridview的情况下将参数传递给asp.net中的页面
这是表,这可能吗?
<table id="myTable">
<thead>
<tr>
<th>Version
</th>
<th>Description
</th>
<th>Codeline
</th>
<th>BuildStatus
</th>
<th>Last Build Date
</th>
<th>Owner
</th>
<th>ReleaseID
</th>
<th>Action
</th>
</tr>
</thead>
<tbody>
<% if (packages != null)
{ %>
<% foreach (var item in packages)
{ %>
<tr>
<td>
<% = item.BuildVersion %>
</td>
<td>
<%= item.Description %>
</td>
<td>
<%= item.Codeline %>
</td>
<td>
<%= item.BuildStatus %>
</td>
<td>
<%= item.LastBuildDate %>
</td>
<td>
<%= item.BulidOwner %>
</td>
<td>
<%= item.ReleaseId %>
</td>
<td>
select row link here
</td>
</tr>
<% } %>
<%} %>
</tbody>
</table>
答案 0 :(得分:0)
使用带命令名称和commandArgumnet的转发器。
答案 1 :(得分:0)
只需在行上添加一个id,然后在你想要的td上添加一个click事件。
function GetData(clickedtd) {
//id will be row identifier
var id = $(clickedtd).parent().attr('id');
var result = "";
$("#"+id + " > td").each(function () {
result += "&" + $(this).text();
});
//Send request to the server **here!!!**
alert(result.replace(/(\r\n|\n|\r)/gm, ""));
}
<div>
<table id="myTable">
<thead>
<tr>
<th>Version
</th>
<th>Description
</th>
<th>Codeline
</th>
<th>BuildStatus
</th>
<th>Last Build Date
</th>
<th>Owner
</th>
<th>ReleaseID
</th>
<th>Action
</th>
</tr>
</thead>
<tbody>
<% if (packages != null)
{ %>
<% foreach (var item in packages)
{/*row id should be unique key*/ %>
<tr id= "<% = item.Codeline %>" >
<td>
<% = item.BuildVersion %>
</td>
<td>
<%= item.Description %>
</td>
<td>
<%= item.Codeline %>
</td>
<td>
<%= item.BuildStatus %>
</td>
<td>
<%= item.LastBuildDate %>
</td>
<td>
<%= item.BulidOwner %>
</td>
<td>
<%= item.ReleaseId %>
</td>
<td onclick="GetData(this);">
select row link here
</td>
</tr>
<% } %>
<%} %>
</tbody>
</table>