
04/03/2005, 09:35
|
 | | | Fecha de Ingreso: diciembre-2004
Mensajes: 365
Antigüedad: 20 años, 4 meses Puntos: 1 | |
Neivan otra consulta, ¿El valor del lado de la igualdad de la variable de session tiene que se igual a Si o No, porque? no entiendo porque. Veras todo el page load de la pag lo agregue igual a no. De la siguiente manera
Sub Page_Load(Sender As Object, E As EventArgs)
viewstate("MbpA")= "no"
If Not IsPostBack
Dim ds As DataSet
Dim MyConnection As SqlConnection
Dim MyCommand As SqlDataAdapter
ds = New DataSet ()
MyConnection = New SqlConnection("SERVER=MDS01; DATABASE=be; INTEGRATED SECURITY=false;PASSWORD=sa;USER=sa")
MyCommand = New SqlDataAdapter ("select EstadoID, Nombre_Estado from Estado" , MyConnection)
MyCommand.Fill(ds,"Estado")
DropDownList1.DataSource = ds.Tables("Estado").DefaultView
DropDownList1.DataTextField = "Nombre_Estado"
DropDownList1.DataValueField ="EstadoID"
DropDownList1.DataBind()
DropDownList1.Items.Insert(0, "Seleccione un item")
DropDownList1.SelectedIndex = 0
end if
end sub
No me queda claro si agregarlo dentro del bloque If not ispostback
ademas lo agregue en el evento DropDownList1_SelectedIndexChanged
Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
viewstate("MbpA")= "si"
'Cargo drop2
end sub
luego finalmente el control buton
Dim i As Int32
Dim j As Int32
Dim strSql As String
if viewstate("MbpA")= "si"
'Cargo el combo busqueda
For i = 0 to Check1.Items.Count-1
if Check1.selectedindex=-1 Then
Iblmessage.Text = "Es necesario que seleccione un servicio"
Else If Check1.Items(i).Selected Then
Iblmessage.Text=""
Dim ds As DataSet
Dim MyConnection As SqlConnection
Dim MyCommand As SqlDataAdapter
strSql = " SELECT "
For j = 0 To Check1.Items.Count - 1
If Check1.Items(j).Selected Then
' Entra si esta seleccionado
strSql += " " & Check1.Items(j).value & ", "
end if
Next
strSql += " Agencia.Agencia as Agencia, Agencia.Direccion as Direccion, Agencia.Telefono as Telefono, Estado.Nombre_Estado as Estado, Ciudad.Nombre_Ciudad as Ciudad, Ubicacion.Descripcion as Ubicación From Agencia, Estado, Ciudad, Ubicacion "
strSql += " WHERE Agencia.EstadoID=Estado.EstadoID"
strSql += " AND Agencia.CiudadID=Ciudad.CiudadID"
strSql += " AND Agencia.UbicacionID=Ubicacion.UbicacionID"
strSql += " AND Agencia.EstadoID=" &DropDownList1.SelectedItem.Value
strSql += " AND Agencia.CiudadID=" &DropDownList2.SelectedItem.Value
strSql += " AND Agencia.UbicacionID=" &DropDownList3.SelectedItem.Value
Else if viewstate("MbpA")= "no"
strSql += "Select Agencia.Identificador as Agencia, Agencia.Direccion as Direccion, Agencia.Telefono as Telefono, Agencia.Cajero_Automatico as Cajero_Automatico, Agencia.Autobanco as Autobanco, Agencia.Taquilla_Externa as Taquilla_Externa, Agencia.Estacionamiento as Agencia_Estacionamiento, Estado.Nombre_Estado as Estado, Ciudad.Nombre_Ciudad as Ciudad, Ubicacion.Descripcion as Ubicación From Agencia, Estado, Ciudad, Ubicacion "
strSql += " WHERE Agencia.EstadoID=Estado.EstadoID"
strSql += " AND Agencia.CiudadID=Ciudad.CiudadID"
strSql += " AND Agencia.UbicacionID=Ubicacion.UbicacionID"
For j = 0 To Check1.Items.Count - 1
If Check1.Items(j).Selected Then
' Entra si esta seleccionado
strSql += " AND " & Check1.Items(j).value & "='si' "
end if
Next
end if
next
end if
End Sub |