<table style="width: 850px" class="Tbl_solid" style="background-color: white;" border="0"
cellspacing="0" cellpadding="0" >
<asp:Repeater ID="rptList" runat="server">
<ItemTemplate>
<tr id="" align="center">
<td align="center" id="td_KENSYU_MEI_KJ" runat="server" visible="false" >
<input id="Name" type="text" onfocus="rowSelect(this)" onkeyup="changeText()" runat="server"
value='<%#Eval("KENSYU_MEI_KJ") %>' style="width: 99%; text-align: left; height: 18px;" />
</td>
<td align="center" id="td_JOBNO" runat="server" visible="false">
<input id="txt_JOBNO" type="text" onfocus="rowSelect(this)" onkeyup="changeText()" runat="server"
value='<%#Eval("JOBNO") %>' style="width: 99%; text-align: left; height: 18px;" />
</td>
<td align="center" id="td_JIKAN_SU" runat="server" visible="false">
<input id="txt_JIKAN_SU" type="text" onfocus="rowSelect(this)" onkeyup="changeText()" runat="server"
value='<%#Eval("JIKAN_SU") %>' style="width: 99%; text-align: left; height: 18px;" />
</td>
<td align="center" id="td_SYUKAN_MEI_KJ" runat="server" visible="false">
<input id="txt_SYUKAN_MEI_KJ3" type="text" onfocus="rowSelect(this)" onkeyup="changeText()" runat="server"
value='<%#Eval("SYUKAN_MEI_KJ") %>' style="width: 99%; text-align: left; height: 18px;" />
</td>
<td align="center" id="td_YOUSI_NAIYO" runat="server" visible="false">
<input id="Theme" type="text" onfocus="rowSelect(this)" runat="server" value='<%#Eval("YOUSI_NAIYO") %>'
style="width: 99%; text-align: left; height: 18px;" />
</td>
<td align="left" id="td_STA_YMD" runat="server" visible="false">
<input id="DateFrom" type="text" runat="server" value='<%#Eval("STA_YMD") %>' class="Wdate"
onfocus="WdatePicker(),rowSelect(this)" style="width: 99%; text-align: center;" />
</td>
<td align="left" id="td_END_YMD" runat="server" visible="false">
<input id="DateTo" type="text" runat="server" value='<%#Eval("END_YMD") %>' class="Wdate"
onfocus="WdatePicker(),rowSelect(this)" style="width: 99%; text-align: center;" />
</td>
<td style="display: none">
<asp:HiddenField ID="HFKensyuSeq" runat="server" Value='<%#Eval("CPD_KENSYU_SEQ") %>' />
</td>
<td style="display: none">
<asp:HiddenField ID="HFJobSeq" runat="server" Value='<%#Eval("JOB_SEQ") %>' />
</td>
<td style="display: none">
<asp:HiddenField ID="HFSortId" runat="server" Value='<%#Eval("SORT_ID") %>' />
</td>
<td style="display: none">
<asp:HiddenField ID="HFExistFlg" runat="server" Value='<%#Eval("EXIST_FLG") %>' />
</td>
<td style="display: none">
<asp:HiddenField ID="HFJobNo" runat="server" Value='<%#Eval("JOBNO") %>' />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
</table>
代碼大約是這樣,我想從後台控制table的某幾列的顯示和隱藏,但是Repeater裡的td的id後台獲取不到
添加OnItemDataBound事件獲取td進行顯示隱藏
<asp:Repeater ID="rptList" runat="server" OnItemDataBound="TdOp">
protected void TdOp(object sender, RepeaterItemEventArgs e)
{
HtmlTableCell c = e.Item.FindControl("td_KENSYU_MEI_KJ") as HtmlTableCell;
Response.Write(c == null);
if (c != null /*&& 你的條件*/) c.Visible = true;
//....其他的td
}