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>

    
    
    
    
    
    

  • 相关阅读:
    数据结构-树与二叉树-思维导图
    The last packet successfully received from the server was 2,272 milliseconds ago. The last packet sent successfully to the server was 2,258 milliseconds ago.
    idea连接mysql报错Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property
    redis学习笔记
    AJAX校验注册用户名是否存在
    AJAX学习笔记
    JSON学习笔记
    JQuery基础知识学习笔记
    Filter、Listener学习笔记
    三层架构学习笔记
  • 原文地址:https://www.cnblogs.com/wangzl1163/p/6341169.html
Copyright © 2011-2022 走看看