【问题标题】:c# asp.net repeater - create button based on conditionc# asp.net repeater - 根据条件创建按钮
【发布时间】:2012-08-09 08:50:01
【问题描述】:

基本上,我想做的是有一个按钮,该按钮仅为在单独的表中标记为发送的条目创建。因此,例如,如果我编辑一条记录,我标记另一个表,并希望通过下面的中继器在该记录旁边显示一个发送按钮 - 这可能吗?我可以通过调用例如不确定的方法来进行检查吗:(

<asp:Repeater ID="DepartmentsList" runat="server">
            <HeaderTemplate>
               <table id="grouptable" class="table table-bordered table-striped"> 
                <thead>
                        <tr>
                        <th>Send</th>
                        <th>ID</th>
                        <th>Name</th>
                        <th>Last Modified</th>
                        <th>Actions</th>
                    </tr>
                    </thead>
                    <tbody>
            </HeaderTemplate>
            <ItemTemplate>
                        <tr>
                        <td>
                        <input type="checkbox" name="sendSelect[]" value="<%# Eval("Dept_ID") %>"</input></td>
                        <td><%# Eval("Dept_ID") %></td>
                        <td><a href="<%# Eval("gURL") %>"><%# Eval("DESC") %></a> </td>
                        <td><%# Eval("CHG_DATE") %></td>
                        <td><a class="btn btn-info" href="<%# Eval("gURL") %>"><i class="icon-pencil icon-white"></i> Edit</a><asp:Button ID="Button1" runat="server" Text="Send" /></td>
                        </tr>
            </ItemTemplate>
            <FooterTemplate>
                        </tbody>
                </table>
            </FooterTemplate>
            </asp:Repeater>

【问题讨论】:

    标签: c# asp.net asprepeater


    【解决方案1】:

    您可以使用DepartmentsList_OnItemDataBound 事件来检查和检查当前绑定到中继器的数据记录。它为您提供了动态更改转发器项目中绑定和创建的内容所需的所有功能。

    【讨论】:

    • 链接的 MSDN 页面上有一个不错的示例。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-25
    • 2021-01-06
    相关资源
    最近更新 更多