获取列表视图中单击的超链接的索引

时间:2015-01-08 07:18:57

标签: asp.net listview

使用列表视图从数据库中显示数据如下。我在列表中有一个超链接查看点击我需要设置会话与所点击的项目的id或数据键row.how我可以得到它吗?

 <asp:ListView ID="lstvwResultInquiry" runat="server" DataKeyNames="inquiry_id" 
onitemdatabound="ListView1_ItemDataBound" 
onpagepropertieschanging="PagePropertiesChanging" 
onitemcanceling="CancelListViewItem" onitemediting="EditListViewItem" 
onselectedindexchanging="lstvwResultInquiry_SelectedIndexChanging" >
<LayoutTemplate >
 <div id="rightnowIn">
<table  class="gridview"cellpadding="5" cellspacing="5" >
<tr class="header">                                                               
<th width="140">Company</th>
<th width="220">Event</th>
<th width="125">Country</th>
<th width="125">Date</th>
<th width="100">Details</th>                                                                                                                   
</tr>
  <tr id="itemPlaceholder" runat="server" />
 <tr id="Tr1"  runat="server" align="center" >
   <td colspan="2" align="left"><asp:Label ID="lblCount" runat="server"></asp:Label></td>
    <td id="Td1"  runat="server" style="" colspan="4">
 <asp:DataPager class="mpart" ID="DataPager1" PageSize="15" runat="server" align="center">
<Fields>                              
<asp:NumericPagerField ButtonType="Link"ButtonCount="3" PreviousPageText="<<<" NextPageText=">>>" />     
 </Fields>
 </asp:DataPager>    
 </td>
   <td colspan="2" align="left"></td></tr></table>
</LayoutTemplate>
 <ItemTemplate >
<tr class="itemTemplateTr" >
 <td style="color: #403f3f; font-weight: bold;"><%# Eval("company")%></td>
 <td><asp:Label  ID="lblEvents" runat="server" ></asp:Label></td>
 <td><%# Eval("country_name")%></td>
 <td><%# Eval("date", "{0:dd-MM-yyyy}")%></td>
<%   if (Session["session_log_id"] != null)
 { %>
<td class="command"><asp:HyperLink ID="btnEdit" runat="server" Text="View" commandName="view" cssclass="linkEditButton"  Font-Underline="True"/</td                                                                                 
<%} %>
<td>
<asp:Button ID="buttReminder"  runat="server" Visible="false" CssClass="reminderButton"  CommandArgument='<%# Eval("inquiry_id")%>' OnClick="buttReminderInquiry_Click"   BorderStyle="None" /></td> </tr> 
</ItemTemplate>           
<AlternatingItemTemplate>
<tr class="alternatingItem">                                                          
<td style="color: #403f3f; font-weight: bold;"><%# Eval("company")%></td>
<td><asp:Label  ID="lblEvents" runat="server"  ></asp:Label></td>
 <td><%# Eval("country_name")%></td>
<td><%# Eval("date", "{0:dd-MM-yyyy}")%></td>
  <%   if (Session["session_log_id"] != null)
 { %>
<td class="command"><asp:HyperLink ID="btnEdit" runat="server" Text="View"  cssclass="linkEditButton"  Font-Underline="True"  /></td>                                           
 <%}   %> 
<td>
<asp:Button ID="buttReminder"  runat="server" Visible="false" CssClass="reminderButton"  CommandArgument='<%# Eval("inquiry_id")%>' OnClick="buttReminderInquiry_Click"   BorderStyle="None" /></td>                                   
</tr></AlternatingItemTemplate>
<EmptyDataTemplate>
<div style="text-align:center;font-weight:bold">0 Results Founds</div> 
</EmptyDataTemplate>
</asp:ListView>

现在我想知道点击超链接时点击的行索引。我想用所选行上的datakey设置会话,即点击的超链接。

0 个答案:

没有答案