locked
change link ID dynamically as per record in repeater RRS feed

  • Question

  • User-1998474842 posted

    Hi guys

    below asp:LinkButtonin section PRID always display ID record number one. i want to dynamically change ID as pear records . how can do it ?

    Bo_Kren.aspx?PRID=1&COID=1&COBUID=1&COBULEID=1&COBULEAPID=1

    i want change orange color above as pear records.

                            <asp:Repeater ID="Product_Item_1" runat="server" onitemcreated="BooksRepeater_ItemCreated">
                                <ItemTemplate>
                                    <div id="item">
                                        <asp:HyperLink ID="PMN_Pega_Viewmore" runat="server" NavigateUrl='<%# Eval("PRID", "?PRID={0}&COID=" + Request.QueryString["COID"] + "&COBUID=" + Request.QueryString["COBUID"] + "&COBULEID=" + Request.QueryString["COBULEID"] + "&COBULEAPID=" + Request.QueryString["COBULEAPID"] + "") %>'>
                                            <img alt='<%# Eval("Product_Names") %>' runat="server" src='<%# Eval("Product_Images") %>' />
                                        </asp:HyperLink>
                                        <asp:LinkButton ID="txtPRID" runat="server" Text='<%# Eval("PRID") %>' CommandArgument='<%# Eval("PRID") %>'></asp:LinkButton>
                                        <asp:Label ID="nawPRID" runat="server" Text='<%# Eval("PRID") %>'></asp:Label>
                                    </div>
                                </ItemTemplate>
                                <HeaderTemplate>
                                </HeaderTemplate>
                            </asp:Repeater>
        protected void BooksRepeater_ItemCreated(object sender, RepeaterItemEventArgs e)
        {
            ScriptManager scriptMan = ScriptManager.GetCurrent(this);
            LinkButton btn = e.Item.FindControl("txtPRID") as LinkButton;
            if (btn != null)
            {
                btn.Click += TxtPRID_Click;
                scriptMan.RegisterAsyncPostBackControl(btn);
            }
    
        }
    
        protected void TxtPRID_Click(object sender, EventArgs e)
        {
            foreach (RepeaterItem item in Product_Item_1.Items)
    
            {
    
                if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
    
                {
    
                    var box = (Label)item.FindControl("nawPRID");
    
                    Response.Redirect("Bo_Kren.aspx?PRID=" + box.Text + "&COID=" + Request.QueryString["COID"] + "&COBUID=" + Request.QueryString["COBUID"] + "&COBULEID=" + Request.QueryString["COBULEID"] + "&COBULEAPID=" + Request.QueryString["COBULEAPID"]);
    
                }
    
            }   
            
    
        }
    

    Sunday, December 2, 2018 10:02 AM

Answers

  • User-1716253493 posted

    You shouldn't loop repeater items

        protected void TxtPRID_Click(object sender, EventArgs e)
        {
            LinkButton TxtPRID = (LinkButton)sender;
            var box = (Label)TxtPRID.NamingContainer.FindControl("nawPRID");
            Response.Redirect("Bo_Kren.aspx?PRID=" + box.Text + "&COID=" + Request.QueryString["COID"] + "&COBUID=" + Request.QueryString["COBUID"] + "&COBULEID=" + Request.QueryString["COBULEID"] + "&COBULEAPID=" + Request.QueryString["COBULEAPID"]);
        }

    NamingContainer is the repeateritem

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, December 2, 2018 11:53 AM

All replies

  • User-1716253493 posted

    You shouldn't loop repeater items

        protected void TxtPRID_Click(object sender, EventArgs e)
        {
            LinkButton TxtPRID = (LinkButton)sender;
            var box = (Label)TxtPRID.NamingContainer.FindControl("nawPRID");
            Response.Redirect("Bo_Kren.aspx?PRID=" + box.Text + "&COID=" + Request.QueryString["COID"] + "&COBUID=" + Request.QueryString["COBUID"] + "&COBULEID=" + Request.QueryString["COBULEID"] + "&COBULEAPID=" + Request.QueryString["COBULEAPID"]);
        }

    NamingContainer is the repeateritem

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, December 2, 2018 11:53 AM
  • User-1998474842 posted

    thank you very much .

    Sunday, December 2, 2018 12:34 PM