Ver Mensaje Individual
  #4 (permalink)  
Antiguo 06/06/2011, 11:44
alexg88
 
Fecha de Ingreso: abril-2011
Mensajes: 1.342
Antigüedad: 13 años
Puntos: 344
Respuesta: Consulta con variable en GridView

Ah claro, no me había fijado. Como estás utilizando etiquetas asp no se puede poner <%= %> dentro de ellas.

Tendrás que usar las etiquetas <selectparameters> y <asp:SessionParameter>:

Código ASP:
Ver original
  1. <div class="gensoporte">
  2.        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
  3.                ConnectionString="<%$ ConnectionStrings:trackpasoConnectionString %>" SelectCommand="SELECT DISTINCT W.WORKITEMKEY, S.LABEL as ESTADO, W.PACKAGESYNOPSYS
  4. FROM TWORKITEM as W, TSTATE as S, TCLIENTE as C
  5. WHERE (W.STATE = S.PKEY)
  6. AND
  7. (W.CLIENTEKEY = C.PKEY)
  8. AND (C.LABEL = @var_user)
  9. AND (S.LABEL != 'closed')">
  10. <SelectParameters>
  11.                <asp:SessionParameter Name="var_user" SessionField="var_user" Type="String" />    
  12.           </SelectParameters>
  13. </asp:SqlDataSource>
  14.            <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
  15.                DataSourceID="SqlDataSource1">
  16.            </asp:GridView>
  17.            <asp:Label ID="label11" runat="server" Text="Label"></asp:Label>
  18.        
  19.     </div>

Pero, tendrás que cambiar el Context por Session:

Código vb:
Ver original
  1. Public Class soporte
  2.     Inherits System.Web.UI.Page
  3.  
  4.  
  5.  
  6.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  7.         Dim strUser As String = System.Web.HttpContext.Current.User.Identity.Name
  8.         Me.label11.Text = strUser
  9.         Session.Add("var_user", strUser);
  10.      
  11.     End Sub
  12.  
  13. End Class