HtmlTableRow 서버 컨트롤 선언 구문

업데이트: 2007년 11월

<tr> HTML 요소에 매핑되는 서버측 컨트롤을 만들어 표의 행을 만들고 조작할 수 있도록 합니다.

<tr 
    EnableViewState="False|True"
    Id="string"
    Visible="False|True"
    OnDataBinding="OnDataBinding event handler"
    OnDisposed="OnDisposed event handler"
    OnInit="OnInit event handler"
    OnLoad="OnLoad event handler"
    OnPreRender="OnPreRender event handler"
    OnUnload="OnUnload event handler"
    runat="server"
    >
  
   <td>cellcontent</td> 
   <td>cellcontent</td> 
   <td>cellcontent</td> 
  
</tr>

설명

HtmlTableRow 클래스를 사용하여 <tr> HTML 요소를 프로그래밍할 수 있습니다. <tr> 요소는 표의 행을 나타냅니다.

HtmlTableRow 클래스를 사용하면 표에서 각 행의 모양을 제어할 수 있습니다. BgColor, BorderColorHeight 속성을 설정하여 각각 행의 배경색, 테두리 색 및 높이를 제어할 수 있습니다.

행에서 셀 내용의 가로 및 세로 맞춤은 각각 AlignVAlign 속성을 설정하여 제어됩니다.

표의 각 행에는 Cells 컬렉션이 포함되어 있고 이 컬렉션에는 행의 각 셀에 대한 HtmlTableCell이 포함되어 있습니다.

예제

다음 예제에서는 HtmlTableCell을 사용하여 HtmlTable 컨트롤의 셀 내용을 수정하는 방법을 보여 줍니다.

<%@ Page Language="VB" AutoEventWireup="True" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head>
<title>HtmlTableRow Control</title>

   <script runat="server">
       Sub Button_Click(ByVal sender As Object, ByVal e As EventArgs)

           Dim i As Integer
           Dim j As Integer

           ' Iterate through the rows of the table.
           For i = 0 To Table1.Rows.Count - 1

               ' Iterate through the cells of a row.       
               For j = 0 To Table1.Rows(i).Cells.Count - 1

                   ' Change the inner HTML of the cell.
                   Table1.Rows(i).Cells(j).InnerHtml = "Row " & i.ToString() _
                                                       & ", Column " & _
                                                       j.ToString()
               Next j

           Next i
       End Sub
   </script>

</head>
<body>

   <form id="Form1" runat="server">

      <h3>HtmlTableCell Example</h3>

          <table id="Table1" runat="server" 
                style="border-width: 1; border-color: Black">

         <tr>
            <td>
               Cell 1
            </td>
            <td>
               Cell 2
            </td>
         </tr>
         <tr>
            <td>
               Cell 3
            </td>
            <td>
               Cell 4
            </td>
         </tr>

      </table>


      <br /><br />

      <input id="Button1" type="button" 
             value="Change Table Contents"
              onserverclick="Button_Click" 
             runat="server"/>
   </form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="True" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head>
<title>HtmlTableRow Control</title>

   <script runat="server">
      void Button_Click(Object sender, EventArgs e) 
      {

         // Iterate through the rows of the table.
         for (int i=0; i<=Table1.Rows.Count - 1; i++)
         {

            // Iterate through the cells of a row.
            for (int j=0; j<=Table1.Rows[i].Cells.Count - 1; j++)
            {
               // Change the inner HTML of the cell.
               Table1.Rows[i].Cells[j].InnerHtml = "Row " + i.ToString() + 
                                                   ", Column " + 
                                                   j.ToString(); 
            }

         }

      }
   </script>

</head>
<body>

   <form id="Form1" runat="server">

      <h3>HtmlTableCell Example</h3>

          <table id="Table1" runat="server" 
                style="border-width: 1; border-color: Black">

         <tr>
            <td>
               Cell 1
            </td>
            <td>
               Cell 2
            </td>
         </tr>

         <tr>
            <td>
               Cell 3
            </td>
            <td>
               Cell 4
            </td>
         </tr>

      </table>


      <br /><br />

      <input id="Button1" type="button" 
             value="Change Table Contents"
             onserverclick="Button_Click" 
             runat="server"/>

   </form>
</body>
</html>

참고 항목

참조

HtmlTableRow

HtmlTableCell 서버 컨트롤 선언 구문

HtmlTable 서버 컨트롤 선언 구문

System.Web.UI.HtmlControls

기타 리소스

HTML 서버 컨트롤