2012-02-10 8 views
0

나는 사용자가 div에서 (div는 내 열을 클릭 할 때 해당 행에 내 첫 번째 열 ('Proposta'라고도 함) Conversa ').어떻게 내 gridview에서 셀의 값을 얻을 수

Jquery를 통해 어떻게 할 수 있습니까?

내 ASPX 내 HTML 렌더링

 <asp:TemplateField HeaderText="Conversa"> 
      <ItemTemplate> 
       <div style="width:30px;"> 
         <div id="lblConversa">Conversa</div> 
       </div> 
      </ItemTemplate> 
     </asp:TemplateField> 

     <asp:TemplateField HeaderText="Ação"> 
      <ItemTemplate> 
       <%= acao %> 
      </ItemTemplate> 
     </asp:TemplateField> 
    </Columns> 
</asp:GridView> 

<table class="StyleGrid" cellspacing="0" border="0" id="grdDetalheProposta" style="border-width:0px;width:100%;border-collapse:collapse;"> 
     <tr class="thGrid" style="color:#000000;background-color:#E2DCD2;height:20px;"> 
      <th scope="col">Proposta</th><th scope="col">Data</th><th scope="col">Valor</th><th scope="col">Coment&#225;rio</th><th scope="col">Inserido Por</th><th scope="col">Credenciada Proponente</th><th scope="col">Status</th><th scope="col">Conversa</th><th scope="col">Ação</th> 
     </tr><tr class="EstiloDalinhaGrid" align="center"> 
      <td>208194</td><td style="width:1px;">29/12/2011 14:32:13</td><td>11,11</td><td>Teste 1</td><td>Fl&#225;vio Oliveira Santana</td><td>Central de Opera&#231;&#245;es</td><td>Andamento</td><td> 
       <div style="width:30px;"> 
         <div id="lblConversa">Conversa</div> 
       </div> 
      </td><td> 

      </td> 
     </tr> 
    </table> 
클릭 이벤트 처리기에서
+1

정확한 속는 http://stackoverflow.com/questions/376081/ 방법 - 얻을 - 테이블 - 셀 - 값 - 사용 - jquery – Devjosh

+0

나는이 링크에 대한 해결책을 이해하지 못한다. –

답변

1

는 같은 tr에서 첫 번째 자식 td의 뒤쪽으로는 tddiv에서 이동 :

$('#grdDetalheProposta td > div').click(function() { 
    var proposta = $(this).closest('td').prevAll('td:first-child').text(); 

    // proposta contains the value of the first td in the same row 
}); 
관련 문제