2013-11-01 4 views
0
<asp:Table ID="tbl_Main" runat="server"> 
    <asp:TableRow> 
     <asp:TableCell> 
    **<a href=""> </a>** 
     </asp:TableCell> 
    </asp:TableRow> 
</asp:Table> 

아주 기본적인 허? 필자는 다음과 같이 뭔가 뒤에 코드에서이 문제를 채우는 : 당신이 볼 수 있듯이동적으로 생성 된 앵커

 int rowCount = myset.Tables[0].Rows.Count; 
     int cellCount = myset.Tables[0].Columns.Count; 
     for (int rowCtr = 1; rowCtr <= rowCount; rowCtr++) 
     { 
      // Create new row and add it to the table. 
      TableRow tRow = new TableRow(); 
      tbl_Main.Rows.Add(tRow); 
      for (int cellCtr = 1; cellCtr <= cellCount; cellCtr++) 
      { 
       // Create a new cell and add it to the row. 
       TableCell tCell = new TableCell(); 
       tCell.ID = BuildMyPath(rowCtr.ToString(), cellCtr.ToString()); 
       tCell.Text = "Row " + rowCtr + ", Cell " + cellCtr; 
       tRow.Cells.Add(tCell); 
      } 
     } 

은 필자 내가 셀의 HREF 내에서 값을하고 싶은 T- 세포에 ID를 추가했다.

이제 SO에서 모든 평가 식을 시도했지만 그 중 아무 것도 작동하지 않았습니다.

<a href="<%= Eval("tCell.ID")%>"> </a> 

감사 : 기본적으로 내가 좋아하는 일을하고 싶습니다.

답변

0

디자인 :

코드
<div id="anchor" runat="server"> 

</div> 

당신은 설정해야합니다 뒤에 :

anchor.InnerHtml="Div Content"; //Same use for <a> tag 

또는 당신은 내가 해결 한

+0

나는 피하려고합니다. 다른 div와 평가 사용법을 이해하게 –

0

을 설정하려면 어떤이 LiteralControl를 사용하여 :

tCell.Controls.Add(new LiteralControl(string.Format("<a href={0}>{1}</a>", myPath, textShown))); 
관련 문제