zoukankan      html  css  js  c++  java
  • 通过ItemDataBound事件操作数据控件中嵌套的其他控件

    首先,需要在控件中声明ItemDataBound事件。

    其次,在code文件中实现事件。

    再次,代码示例如下。

    <span style="font-size:14px;">protected void rptPhoto_ItemDataBound(object sender, RepeaterItemEventArgs e)
            {
                if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                {
                    LinkButton lblPRO = e.Item.FindControl("lbtnPro") as LinkButton;
                    Label lbState = e.Item.FindControl("Label1") as Label;
    
                        if (lbState.Text == "-1")
                        {
                            lblPRO.Visible = true;
                        }
                }
            }</span>

    protected void rptPhoto_ItemCommand(object sender, RepeaterCommandEventArgs e)
            {
                Literal litPhotoID = (Literal)e.Item.FindControl("litPhotoID");
                Literal PhotoFilePathFlag = (Literal)e.Item.FindControl("PhotoFilePathFlag");
                Literal PhotoFileName =(Literal)e.Item.FindControl("PhotoFileName");
                int photoID = Convert.ToInt32(litPhotoID.Text);
    
                switch (((LinkButton)e.CommandSource).CommandName)
                {
                    case "Pro":
                        Response.Redirect("/manage/gallery/SaleAuditInfo.aspx?photoid=" + photoID + "&pname=" + PhotoFileName + "&pflag=" + PhotoFilePathFlag);
                        break;
                    case "Edit":
                        Response.Redirect("/manage/gallery/ProductRelationModify.aspx?photoid=" + photoID);
                        break;
                    case"Content":
                        Response.Redirect("/manage/gallery/ContentModify.aspx?photoid=" + photoID);
                        break;
                    case "Others":
                        Response.Redirect("/manage/gallery/OtherContentModify.aspx?photoid=" + photoID);
                        break;
                    case "":
    
                        break;
                }
            }

    <ItemTemplate>

    <td class="itemtd" style="200px;">

           <asp:LinkButton ID="lbtnPro" runat="server" Text="审核 |" CommandName="Pro" Visible="false"></asp:LinkButton>

          <asp:LinkButton ID="lbtnEdit" runat="server" Text="修改类别 |" CommandName="Edit" Visible="false"></asp:LinkButton>

          <asp:LinkButton ID="lbtnContent" CommandName="Content" runat="server">商品详情 |</asp:LinkButton>

          <asp:LinkButton ID="lbtnOthers" CommandName="Others" runat="server">其他</asp:LinkButton>

           <asp:LinkButton ID="lbtnIsSale" CommandName="isSale" runat="server">上架</asp:LinkButton>

    </td>

    </tr>

    </ItemTemplate>

    
    
    
    
    
    

  • 相关阅读:
    微服务之初识微服务
    常见的认证机制及JSON WEB TOKEN
    深入理解缓存之缓存预热与淘汰策略
    深入理解缓存之缓存和数据库的一致性
    深入理解缓存之缓存存在的问题及应对措施
    深入理解缓存之常见的缓存算法
    计算机网络之HTTP、HTTPS、HTTP2
    计算机网络之TCP(三次握手、四次挥手等),UDP及DNS
    计算机网络之网络体系架构与IP
    深入理解MyBatis(四)--缓存
  • 原文地址:https://www.cnblogs.com/wangzl1163/p/6341169.html
Copyright © 2011-2022 走看看