Pero ahora, le hize unos ajustes al grid y cuando se efectua le doy a buscar por los parametros de Crago y profesion, pues no lo hace y no porque ahora no lo hace cuando antes si

de esta forma hacia la consulta
<script language="VB" runat="server">
Dim SelectCommand As String = "Select SolicitudID, Cargo_Solicitado, Apellidos_Nombres, Fecha_Nacimiento, Sexo, Profesion, Telefono_Hab, Empleado_Actualmente From SolicitudEmpleo"
Sub Page_Load(Sender As Object, E As EventArgs)
If Not IsPostBack
Dim ds As DataSet
Dim MyCommand As SqlDataAdapter
MyCommand = New SqlDataAdapter ("select CargoID, Nombre_Cargo from Cargo_Solicitado" , PortalSettings.SqlConnectionString)
ds = New DataSet ()
MyCommand.Fill(ds,"Cargo_Solicitado")
DropDownList1.DataSource = ds.Tables("Cargo_Solicitado").DefaultView
DropDownList1.DataTextField = "Nombre_Cargo"
DropDownList1.DataValueField ="CargoID"
DropDownList1.DataBind()
DropDownList1.Items.Insert(0, "Seleccione un item")
DropDownList1.SelectedIndex = 0
Dim dc As DataSet
Dim MyCommand2 As SqlDataAdapter
MyCommand2 = New SqlDataAdapter ("select ProfesionID, Nombre_Profesion from Profesion", PortalSettings.SqlConnectionString)
dc = New DataSet ()
MyCommand2.Fill(dc,"Profesion")
DropDownList2.DataSource = dc.Tables("Profesion").DefaultView
DropDownList2.DataTextField = "Nombre_Profesion"
DropDownList2.DataValueField = "ProfesionID"
DropDownList2.DataBind()
DropDownList2.Items.Insert(0, "Seleccione un item")
DropDownList2.SelectedIndex = 0
bingrid (SelectCommand)
end if
end sub
Sub Button1_click (sender As Object, e As EventArgs)
If DropDownList1.SelectedIndex then
SelectCommand += " INNER JOIN Cargo_Solicitado "
SelectCommand += " ON SolicitudEmpleo.CargoID= Cargo_Solicitado.CargoID"
SelectCommand += " WHERE SolicitudEmpleo.Cargo_Solicitado = Cargo_Solicitado.Nombre_Cargo"
SelectCommand += " AND SolicitudEmpleo.CargoID=" &DropDownList1.SelectedItem.Value
bingrid (SelectCommand)
Else if DropDownList2.SelectedIndex then
SelectCommand += " INNER JOIN Profesion"
SelectCommand += " ON SolicitudEmpleo.ProfesionID= Profesion.ProfesionID"
SelectCommand += " WHERE SolicitudEmpleo.Profesion = Profesion.Nombre_Profesion"
SelectCommand += " AND SolicitudEmpleo.ProfesionID=" &DropDownList2.SelectedItem.Value
bingrid (SelectCommand)
end if
end sub
Sub MyDataGrid_Delete(Sender As Object, E As DataGridCommandEventArgs)
Dim MyCommand As SqlCommand
Dim DeleteCmd As String = "DELETE from SolicitudEmpleo where SolicitudID = @SolicitudID"
MyCommand = New SqlCommand(DeleteCmd, PortalSettings.SqlConnectionString)
MyCommand.Parameters.Add(New SqlParameter("@SolicitudID", SqlDbType.NVarChar, 11))
MyCommand.Parameters("@SolicitudID").Value = MyDataGrid.DataKeys(CInt(E.Item.ItemIndex))
MyCommand.Connection.Open()
Try
MyCommand.ExecuteNonQuery()
Message.InnerHtml = "Registro eliminado"
Catch Exc As SQLException
Message.InnerHtml = "ERROR: El registro no puede eliminarse"
Message.Style("color") = "blue"
End Try
MyCommand.Connection.Close()
bingrid (SelectCommand)
End Sub
Sub bingrid (SelectCommand)
Dim DS As DataSet
Dim MyCommand As SqlDataAdapter
MyCommand = New SqlDataAdapter(SelectCommand, PortalSettings.SqlConnectionString)
DS = new DataSet()
MyCommand.Fill(DS, "SolicitudEmpleo")
MyDataGrid.DataSource=DS.Tables("SolicitudEmpleo") .DefaultView
MyDataGrid.DataBind()
end sub
</script>
asi quedo el grid
<ASP:DATAGRID id="MyDataGrid" runat="server" AutoGenerateColumns="False" Width="524px" OnDeleteCommand="MyDataGrid_Delete"
Font-Names="Verdana" DataKeyField="SolicitudID" BorderColor="Black" CellPadding="3" Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd" BackColor="#CCCCFF">
<HeaderStyle BackColor="#AAAADD"></HeaderStyle>
<Columns>
<asp:ButtonColumn Text="Eliminar" CommandName="Delete"></asp:ButtonColumn>
<asp:HyperLinkColumn DataNavigateUrlField="SolicitudID" DataNavigateUrlFormatString="Webform1.aspx?Solicit udID={0}"
Text="ver"></asp:HyperLinkColumn>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="" CancelText="" EditText=""></asp:EditCommandColumn>
<asp:TemplateColumn Visible="False" HeaderText="SolicitudID">
<ItemTemplate>
<asp:Label ID="lblCustomerID" Text='<%# DataBinder.Eval(Container.DataItem,"SolicitudID") %>' Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression="Cargo_Solicitado" HeaderText="Cargo">
<ItemTemplate>
<asp:Label ID="Label8" Text='<%# DataBinder.Eval(Container.DataItem,"Cargo_Solicita do") %>' Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression="Fecha_Nacimiento" HeaderText="Fecha de la Solicitud">
<ItemTemplate>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression="Apellidos_Nombres" HeaderText="Apellido/Nombre">
<ItemTemplate>
<asp:Label ID="Label1" Text='<%# DataBinder.Eval(Container.DataItem,"Apellidos_Nomb res") %>' Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression="Fecha_Nacimiento" HeaderText="Fecha de Nacimiento">
<ItemTemplate>
<asp:Label ID="Label2" Text='<%# DataBinder.Eval(Container.DataItem,"Fecha_Nacimien to") %>' Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression= "Sexo" HeaderText="Sexo">
<ItemTemplate>
<asp:Label ID="Label3" Text='<%# DataBinder.Eval(Container.DataItem,"Sexo") %>' Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression= "Profesion" HeaderText="Profesión">
<ItemTemplate>
<asp:Label ID="Label4" Text='<%# DataBinder.Eval(Container.DataItem, "Profesion") %>' Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression="Telefono_Hab" HeaderText="Teléfono_Hab">
<ItemTemplate>
<asp:Label ID="Label6" Text='<%# DataBinder.Eval(Container.DataItem,"Telefono_Hab") %>' Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression= "Empleado_Actualmente" HeaderText="EA">
<ItemTemplate>
<asp:Label ID="Label7" Text='<%# DataBinder.Eval(Container.DataItem,"Empleado_Actua lmente") %>' Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</ASP:DATAGRID>