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?
 
CodeCruiserCommented:
I have just tested a simplified version of your datalist in my app and it works.

Why do you have EnableEventValidation="false" ?
0
 
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
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
CodeCruiserCommented:
If you hover over e.CommandName, what do you see?
0
 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.