Pues dejame decirte que viste algo fundamental, quite el enlaze del data grid para hacerlo en otro parte y lamarlo desde alli como BinGrid(), y pues nunca agregue el llamado en el codigo del boton

, pues claro ni que el codigo fuera superman para autocompletarse (Un chiste malo

)
Entonces estariamos hablando de algo asi
Sub Button1_Click(sender As Object, e As EventArgs)
Dim i As Int32
Dim j As Int32
Dim strSql As String
if viewstate("MbpA")= "si" then
'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=""
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
BindGrid()
Else if viewstate("MbpA")= "no"
strSql += "Select Agencia.Agencia 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
BindGrid()
next
end if
End Sub
Sub BindGrid()
Dim strSql As String
Dim ds As DataSet
Dim MyConnection As SqlConnection
Dim MyCommand As SqlDataAdapter
MyConnection = New SqlConnection("SERVER=MDS01; DATABASE=be; INTEGRATED SECURITY=false;PASSWORD=sa;USER=sa")
MyCommand = New SqlDataAdapter(strSql, MyConnection)
ds = new DataSet()
MyCommand.Fill(ds, "Agencia")
MyDataGrid.DataSource=ds.Tables("Agencia").Default View
MyDataGrid.DataBind()
end sub
De esta manera no muesta nada cuando no seleccione los combos y cuando los selecciono da un error de
ExecuteReader: CommandText property has not been initialized
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: ExecuteReader: CommandText property has not been initialized
Source Error:
Line 147: MyCommand.Fill(ds, "Agencia")
quizas deba hacer dos eventos bingrid uno para cuando se seleccione y otro para cuando no, pero podria haberte jurado que asi funcionaria