简体   繁体   English

C#asp.net转发器-根据条件创建按钮

[英]c# asp.net repeater - create button based on condition

Basically what i would like to do is have a button which is only created for entries that have been flagged in a separate table for sending. 基本上我想做的是有一个按钮,该按钮仅针对已在单独的表中标记为发送的条目创建。 So for example if i edit a record, i flag this other table and would like a send button to appear next to that record via the repeater below - is this possible? 因此,例如,如果我编辑一条记录,则标记该另一个表,并希望通过下面的转发器在该记录旁边显示一个发送按钮-这可能吗? Can i do a check by calling a method for example unsure :( 我可以通过调用不确定的方法来检查吗:(

<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>

You can do a check and inspect the current data record being bound to the repeater by using the DepartmentsList_OnItemDataBound event. 您可以使用DepartmentsList_OnItemDataBound事件进行检查并检查绑定到转发器的当前数据记录。 It gives you all the power you need to dynamically change what's being bound and created in the repeater's item. 它为您提供了动态更改转发器项目中绑定和创建的内容所需的全部功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM