日期:2014-05-17  浏览次数:20847 次

asp.net之Repeater控件示例
<body>


    
    <form id="form1" runat="server">


    
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1" 
        onitemcommand="Repeater1_ItemCommand">
        <HeaderTemplate>
        <table  id="forum_main" cellpadding="1">
        <thead style="background-color:#03F; border-collapse:separate;" >
<tr>
<td class="table_formname">论坛标题</td>
<td class="table_desc">描述</td>
 
</tr>

</thead>
 <tbody>
        </HeaderTemplate>
        <SeparatorTemplate><hr /></SeparatorTemplate>
        <Itemtemplate>

 <tr style=" color:#000;">
<td style="border:2px #6F0 solid; font-size:16px;" class="table_formname"><a href="formlist.aspx?fid=<%# DataBinder.Eval(Container.DataItem, "fid") %>"><%# DataBinder.Eval(Container.DataItem, "formname") %></a></td>
<td style="border:2px #6F0 solid;" class="table_desc"><a href="#"><%# DataBinder.Eval(Container.DataItem, "describe") %></td>
 <td>
 
 <asp:LinkButton Runat=server CommandName ="del" CommandArgument= '<%# DataBinder.Eval(Container.DataItem,"fid") %>' ID="Linkbutton1" NAME="Linkbutton1">删除</asp:LinkButton>
 </td>
</tr>
</Itemtemplate>
 

<FooterTemplate>
</tbody>
</table>
</FooterTemplate>

        </asp:Repeater>
    </form>
    
    
    
</body>

?

protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            Response.Write("<script>alert('"+e.CommandArgument.ToString()+"');</script>");
        }
?

?