2012-04-12 41 views
0

我能夠得到這個在GridView上工作。 最終,我試圖在點擊時突出顯示一行。 對於測試,我正在使用警報。jquery沒有在Listview tr點擊事件發射

這裏是jQuery的:

$(document).ready(function() { 
    $('#WhiteRow tr').click(function() { 
    event.preventDefault(); 
    alert("white"); 
    }); 

下面是HTML:

<asp:Panel ID="GridViewDrillIntoCell_Panel_All" 
    runat="server" 
    width="2000px" 
    height="380px" 
> 
<asp:ListView ID="GridViewDrillIntoCell_All" 
    runat="server" 
    ScrollBars="Vertical" 
    ItemPlaceholderID= "myItemPlaceHolder" 
    UseAccessibleHeader="True" 
    AutoGenerateColumns="false" 
    HeaderStyle-CssClass="HeaderCss2" 
    OnSelectedIndexChanged="GV_Scorecard_Tab1_SelectedIndexChanged" 
    OnRowDataBound="GridViewDrillIntoCell_All_RowDataBound" 
> 
    <LayoutTemplate> 
    <div id="Listview"> 
     <table border="0" cellpadding="1"> 
     <tr id="HeadingRow"> 
      <th id="hcol1" style="width:50px">Client</th> 
     </tr> 
     <tr> 
      <asp:PlaceHolder ID="myItemPlaceHolder" runat="server"> 
      </asp:PlaceHolder> 
     </tr> 
     </table> 
    </div> 
    </LayoutTemplate> 
    <ItemTemplate> 
    <tr id="WhiteRow"> 
     <td id="col1" class="ListViewStyle" style="width:50px"> 
     <%# Eval("LMClient")%> 
     </td> 
    </tr> 
    </AlternatingItemTemplate>  
</asp:ListView></asp:Panel> 

回答

0

我覺得你的選擇是不正確。

#WhiteRow tr表示選擇位於ID爲WhiteRow的元素內的所有tr元素。所以你正在尋找行內的行。

+0

tr中的所有元素都是td - 除非佔位符更改了內容。爲了簡化,我現在只在表格中嘗試一行。而且我仍然無法讓點擊事件發揮作用。 – user977645 2012-04-12 17:25:11

+0

我能夠得到一個工作。現在再看一下原來的問題...... – user977645 2012-04-12 17:28:48