其生成的HTML代码为:
<table cellspacing="0" rules="all" border="1" id="grd_Account" style="height:63px;width:676px;border-collapse:collapse;">
<tr>
<th scope="col">Account Number</th>
</tr>
<tr>
<td>
<span id="grd_Account_ctl02_Label1_0">Logged</span>
</td>
</tr>
<tr>
<td>
<span id="grd_Account_ctl03_Label1_1">Logged</span>
</td>
</tr>
<tr>
<td>
<span id="grd_Account_ctl04_Label1_2">Logged</span>
</td>
</tr>
</table>
可以看到生成的Label的控件的ID诸如:grd_Account_ctl02_Label1_0正是上面所述格式:父容器控件的ID(grd_Account)+"_"+行号格式(ctl02)+"_"+该控件自身ID(Label1)+"_"+[ClientIDRowSuffix](0)。
<2>如果父容器控件的ClientIDMode值为Static
如果父容器控件或祖先容器控件为显示多个数据行的容器控件,那么该控件的ClientID格式为:该控件自身ID+"_"+[ClientIDRowSuffix],其中ClientIDRowSuffix部分是什么后面会单独说明,其中:该控件自身ID,就是该控件自身ClientIDMode值继承父容器控件ClientIDMode值Static生成的ClientID结果(这里不明白请看前面的Static部分)。 如果父容器控件或祖先容器控件都不是显示多个数据行的容器控件,那么该控件的ClientID格式为:该控件自身ID,可见这个格式就是该控件自身ClientIDMode值继承父容器控件ClientIDMode值Static生成的ClientID结果(这里不明白请看前面的Static部分)。下面我就举一个父容器控件是多数据行容器控件且其ClientIDMode为Static的例子,将上面的代码再做更改,将Label1的ClientIDMode属性值改为Predictable,并且设置其父容器控件grd_Account的ClientIDMode为Static:
<asp:GridView ID="grd_Account" runat="server" AllowPaging="True"
AutoGenerateColumns="False"
DataKeyNames="Account Number" DataSourceID="sds_account" Height="63px"
Width="676px" PageSize="5" ClientIDMode="Static" >
<Columns>
<asp:TemplateField HeaderText="Account Number" Sort ="Account Number">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text="Logged" ClientIDMode="Predictable"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
其生成的HTML代码为:
<table cellspacing="0" rules="all" border="1" id="grd_Account" style="height:63px;width:676px;border-collapse:collapse;">
<tr>
<th scope="col">Account Number</th>
</tr>
<tr>
<td>
<span id="Label1_0">Logged</span>
</td>
</tr>
<tr>
<td>
<span id="Label1_1">Logged</span>
</td>
</tr>
<tr>
<td>
<span id="Label1_2">Logged</span>
</td>
</tr>
</table>








