Don't execute the code for ItemCommand in a datalist

Hello i have a datalist with a asp:button to execute some code, my problem is  that the code is not executed and if i put a stop point don't work

The aspx code is
<asp:Button ID="Button2" runat="server" Text=" Ver todos sus productos" CommandName="VerArticulosDelCliente" CommandArgument='<%# Eval("IdTienda") %>'/>
</ItemTemplate>

in aspx.vb

Protected Sub DataListTiendas_ItemCommand(source As Object, e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles DataListTiendas.ItemCommand
If e.CommandName = "VerArticulosDelCliente" Then
    Dim strCodigoTienda As String = Trim(e.CommandArgument)
            Session("IdTienda") = strCodigoTienda
            Response.Redirect("Default.aspx?B=2")
End If
End Sub
limmontreefreeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CodeCruiserCommented:
Where did you put the break point? Put it on the If line and see if the code within if executes or not.
0
limmontreefreeAuthor Commented:
is in the if line,

don't stop

I think don't execute that code...
0
CodeCruiserCommented:
If you hover over e.CommandName, what do you see?
0
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

limmontreefreeAuthor Commented:
Sorry i don't understand You with "hover"
 Do You mean to place the arrow over the button and watch the link ?

Thanks



Tan la
0
CodeCruiserCommented:
When you are debugging the code (by placing a breakpoint on the code, you can hove (point your mouse) over variables/properties and VS will tell you its current value.
0
limmontreefreeAuthor Commented:
Well i have put some breakpoints but the execution don't stop.

For the DataList i have code for three events:
- prerender
- itemcommand
- SelectedIndexChanged

The execution only stop in the prerender event, I think in the other neither entry.


experts03.png
experts04.png
experts05.png
0
CodeCruiserCommented:
Can you show the full markup?
0
limmontreefreeAuthor Commented:
What's is the full markup?
0
CodeCruiserCommented:
aspx code.
0
limmontreefreeAuthor Commented:
all course,

<%@ page title="" language="VB" masterpagefile="~/MasterOutlet.master" autoeventwireup="false" EnableEventValidation="false"  CodeFile="Tiendas.aspx.vb" Inherits="Tiendas" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 <div id="contenido2">
           <h2><asp:Literal ID="LiteralEncabezado" runat="server"></asp:Literal></h2>
         <div id="filtrar_provincia">
              <p id="filtrar_centro">Buscar tiendas situadas en la provincia
                <asp:DropDownList ID="DropDownTipoProvincia" runat="server">
                </asp:DropDownList>
&nbsp;<asp:Button  ID="btnFiltrar" runat="server" Text="Filtrar" CssClass="boton" />                    
            </p>
           <div id="filtrar_abajo"><!-- --></div>
        </div>
     <asp:SqlDataSource ID="SqlDataSourceTiendas" runat="server"
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="SELECT Member_Id, IdTienda, Nombre_Fiscal, Nombre_Comercial, Lema, Persona_Contacto, Calle, CodPostal, CodProvincia, Poblacion, email, web, Telefono, Fax, logo, activo FROM Tiendas"></asp:SqlDataSource>
            <asp:DataList ID="DataListTiendas" runat="server" DataKeyField="IdTienda"
            DataSourceID="SqlDataSourceTiendas">

                <HeaderTemplate>
                    No hay registros
                </HeaderTemplate>

         <ItemTemplate>
          <div class="tienda">
           <div class="tienda_caja_abajo">
              <div class="tienda_linea">
                 <div class="tienda_izq"> <asp:ImageButton ID="ImageButton6" runat="server" CssClass="img_razas"
                    ImageUrl='<%# "imagelogoFetch2.ashx?Member_Id="& Ctype(Eval("Member_Id"),Guid).toString() %>'
                    CommandName="select" meta:resourcekey="ImageButton1Resource1" Width="80px" /></div>
               <div class="tienda_dch">
         <address>
            <span class="tienda_nombre"><asp:Label ID="Nombre_ComercialLabel" runat="server" Text='<%# Eval("Nombre_Comercial") %>' /></span><br />
             <asp:Label ID="LemaLabel" runat="server" Text='<%# Eval("Lema") %>' /><br />
             <asp:Label ID="CalleLabel" runat="server" Text='<%# Eval("Calle") %>' /><br />
             <asp:Label ID="CodPostalLabel" runat="server" Text='<%# Eval("CodPostal") %>' />
             <asp:Label ID="PoblacionLabel" runat="server" Text='<%# Eval("Poblacion") %>' /> <br />
             Telefono:<asp:Label ID="TelefonoLabel" runat="server" Text='<%# Eval("Telefono") %>' /> <br />
             Fax:<asp:Label ID="FaxLabel" runat="server" Text='<%# Eval("Fax") %>' /><br />
         </address>
              </div>  <%--div con los datos del cliente--%>
               <div class="ver_todo">
                <div class="detalle">
                      <asp:Button ID="Button2" runat="server" Text=" Ver todos sus productos" CommandName="VerArticulosDelCliente" CommandArgument='<%# Eval("IdTienda") %>'/>
                 </div>
                </div>
             </div>
            </div>
            </div>
         </ItemTemplate>

     </asp:DataList>
     <div id="paginacion">Aqui va la paginación</div>
          </div>

          <script type="text/javascript">
          document.getElementById('tres').className = "activo";
          </script>

</asp:Content>
0
CodeCruiserCommented:
Does it work if you click the ImageButton6?
0
limmontreefreeAuthor Commented:
no, and don't pass throught the breakpoints.

thanks
0
CodeCruiserCommented:
I have just tested a simplified version of your datalist in my app and it works.

Why do you have EnableEventValidation="false" ?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
limmontreefreeAuthor Commented:
Hello again:

If i put EnableEventValidation = "true" I obtain an error:

Argument for return or invalid callback. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <% @ Page EnableEventValidation = "true"%> in a page. For security reasons, this feature verifies that arguments to postback events past or callback originates from the server control that initially processed. If the data are valid and expected, use the method for recording data ClientScriptManager.RegisterForEventValidation return or call back for validation.

Are you using EnableEventValidation="true" ?

thanks
0
limmontreefreeAuthor Commented:
Yes, if i Take off the master page, all works fine, i'll be review the master page code.

Thanks.
0
limmontreefreeAuthor Commented:
thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.