2011-01-10 7 views
2

두 개의 목록보기가 있고 각 목록에는 linkbutton이 있습니다. 첫 번째 listview에서 lb를 누르면 이벤트가 발생하지만 두 번째 이벤트에서 lb를 누르면 dosen't가 표시됩니다. 하지만 두 번째 listview 바로 위의 파운드를 놓는다면 그것을 실행합니다.buttons 및 listviews

첫 번째 목록보기 :

<asp:ListView ID="ListViewMesaje" runat="server"> 
    <LayoutTemplate> 
     <ul> 
      <asp:PlaceHolder ID="itemPlaceholder" runat="server" /> 
     </ul> 
    </LayoutTemplate> 
    <ItemTemplate> 
     <asp:LinkButton ID="LinkButtonStergeMesaj" runat="server" CommandName="stergeMesaj" 
             CommandArgument='<%#Container.DataItem%>' OnCommand="LinkButtonListView_Click"><div id="mesajdelete" class='<%#getBackgGifMesaj(getUsernameMesaj((string) Container.DataItem,"citit"))%>'></div></asp:LinkButton> 
    </ItemTemplate> 
</asp:ListView> 

초 하나

<asp:ListView ID="ListViewFriendRequests" runat="server" DataSourceID="SqlDataSourceFriendRequests" > 
     <LayoutTemplate> 
      <ul> 
       <asp:PlaceHolder ID="itemPlaceholder" runat="server" /> 
      </ul> 
     </LayoutTemplate> 
     <ItemTemplate> 
      <asp:LinkButton ID="LinkButtonfqignora" runat="server" CommandName="refuzaPrieten" 
             CommandArgument='<%#Eval("username")%>' OnCommand="LinkButtonListView_Click"><div id="friendreqign" >'<%#Eval("username")%>'</div></asp:LinkButton> 
     </ItemTemplate> 
</asp:ListView> 
+0

사용중인 .net의 버전은 무엇입니까? – Zinc

+0

버전 4.0을 사용 중입니다. – hhh3112

답변

1

마침내 왜 listview 내부의 버튼이 작동하지 않는지에 대한 대답을 발견했습니다. 당신이이처럼의 SqlDataSource에 대한 SelectCommand에, UpdateCommand, DeleteCommand에와에 InsertCommand를 선언 할 필요가 당신의 데이터 소스로서의 SqlDataSource 사용하는 경우 는 : 처음에는

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:Pubs %>" 
        SelectCommand="SELECT [au_id], [au_lname], [au_fname], [state] FROM [authors]" 
        UpdateCommand="UPDATE [authors] SET [au_id] = @au_id, [au_lname] = @au_lname,[au_fname] = @au_fname, [state] = @state WHERE [au_id] = @original_au_id" 
        DeleteCommand="DELETE FROM [authors] WHERE [au_id] = @original_au_id"/> 

을 난 그냥 SelectCommand에 선언하고, 버튼을하지 않았다 이유입니다 해고 당했어.

0

두 가지 제안 : 당신이이 둘 사이의 주요 차이점 것으로 보인다 때문에, DataSourceID 속성을 제거 시도?

또한 링크 단추의 명령 이벤트에 직접 등록하는 대신 ListView의 명령 이벤트를 구독하는 것이 좋습니다. 버튼에서 명령이 실행되면 이벤트가 거품으로 나타나고 listview가이를 취하여 관련 정보와 함께 자체 이벤트를 시작합니다.

관련 문제