Doubt PostBackUrl

2

I'm trying to use PostBackUrl in LinkButton within DataList .

I tried the following, partially successfully.

<asp:LinkButton ID="linkBtnMarca" CommandArgument='<%# Eval("Marca") %>' **PostBackUrl='<%# string.Format("~/User/Produtos.aspx?Marca={0}", Eval("Marca")) %>'** runat="server" OnClick="linkBtnMarca_Click"><%# Eval("Marca") %></asp:LinkButton>

The link in the address bar actually changes depending on the tag when we click on LinkButton , example User/Produtos.aspx?Marca=Bosch , but suppose we do not want to click LinkButton and we want to automatically go to User/Produtos.aspx?Marca=Bosch link, how can I do that? Since without going to LinkButton , it does not work.

Thank you.

EDIT:

Code Behind Brand

        LinkButton lnksender = (LinkButton)sender;
        Session["Marca"] = Convert.ToString(lnksender.CommandArgument);
        lblInfo.Visible = true;
        lblInfos.Visible = true;
        lblInfoGet.Visible = false;
        lblInfosGet.Visible = false;
        lblInfoPesquisa.Visible = false;
        lblInfo.Text = "A filtrar pela marca: ";
        lblInfos.Text = Convert.ToString(Session["Marca"]);
        MultiViewContent.DataBind();
        ViewGridView.DataBind();
        ViewListView.DataBind();
        DataListCategorias.DataBind();
        DataListMarcas.DataBind();
    
asked by anonymous 21.06.2015 / 16:22

1 answer

2

<asp:LinkButton> generates a link within <form> with action = POST . I think a simple link using GET already solves everything:

<a href="~/User/Produtos.aspx?Marca=<%# Eval("Marca") %>"><%# Eval("Marca") %></a>

EDIT

After inserting the link as above, change:

    LinkButton lnksender = (LinkButton)sender;
    Session["Marca"] = Convert.ToString(lnksender.CommandArgument);

By:

    Session["Marca"] = Request.QueryString["Marca"];
    
21.06.2015 / 18:35