程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> .net-如何控制Repeater裡面的項目?

.net-如何控制Repeater裡面的項目?

編輯:編程綜合問答
如何控制Repeater裡面的項目?
<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
    }
lamzyc
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved