Ver Mensaje Individual
  #13 (permalink)  
Antiguo 03/03/2005, 09:46
mjesus20
 
Fecha de Ingreso: marzo-2005
Mensajes: 190
Antigüedad: 20 años
Puntos: 0
te envio mi codigo completo para q lo revices y asi puedas indicarme lo q debo hacer

<%@ Page Language="VB" Debug="True" %>
<script runat="server">

' Insert page code here

Function MyQueryMethod(ByVal ubicacion As String) As System.Data.DataSet
Dim connectionString As String = "server=xxxxxxx; user id='xxxxx'; password=xxxxx; database=xxxxxxxx
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionStri ng)

Dim queryString As String = "SELECT [Inventario].[Lugar], [Inventario].[Equipo], [Inventario].[Modelo], [Inven"& _
"tario].[Serie], [Inventario].[Inventario], [Inventario].[Item] FROM [Inventario]"& _
" WHERE ([Inventario].[Ubicacion] = @Ubicacion) order by lugar "
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dbParam_ubicacion As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_ubicacion.ParameterName = "@Ubicacion"
dbParam_ubicacion.Value = ubicacion
dbParam_ubicacion.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_ubicacion)

Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)

Return dataSet
End Function



Sub pagerbuttonclick(sender As Object, e As EventArgs)
dim arg as string = sender.commandargument
select arg
case "siguiente"
if (datagrid1.currentpageindex < (datagrid1.pagecount - 1)) then
datagrid1.currentpageindex+ =1
end if
case "anterior"
if (datagrid1.currentpageindex >0) then
datagrid1.currentpageindex- =1
end if
case "ultima"
datagrid1.currentpageindex= (datagrid1.pagecount -1)
case "Primera"
datagrid1.currentpageindex=0
end select

datagrid1.datasource=myquerymethod(DropDownList1.S electedItem.Text())
datagrid1.databind
End Sub

sub mi_cambio(sender as object, e as system.web.ui.webcontrols.datagridpagechangedevent args)
datagrid1.currentpageindex=e.newpageindex
datagrid1.datasource=myquerymethod(DropDownList1.S electedItem.Text())
datagrid1.databind
end sub



Function MyQueryMethod2() As System.Data.DataSet
Dim connectionString As String = "server=xxxxxxx; user id='xxxxx'; password=xxxxxx; database=xxxxxxxx
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionStri ng)

Dim queryString As String = "SELECT DISTINCT [Inventario].[Ubicacion] FROM [Inventario]"
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)

Return dataSet
End Function

sub page_load(sender as object, e as eventargs)
if not page.ispostback then
dropdownlist1.datatextfield = "ubicacion"
dropdownlist1.datasource=myquerymethod2()
dropdownlist1.databind()

end if
end sub

Sub DropDownList1_SelectedIndexChanged(sender As Object, e As EventArgs)
datagrid1.datasource=myquerymethod(dropdownlist1.i tems(dropdownlist1.selectedindex).text)
datagrid1.databind()
End Sub

Sub Button1_Click(sender As Object, e As EventArgs)
datagrid1.datasource=myquerymethod(cstr(textbox1.t ext))
datagrid1.databind()
End Sub

Sub DropDownList2_SelectedIndexChanged(sender As Object, e As EventArgs)
datagrid1.datasource=myquerymethod(dropdownlist1.i tems(dropdownlist1.selectedindex).text)
DataGrid1.PageSize=CInt(DropDownList2.SelectedItem .Value)

datagrid1.databind()
End Sub



sub Sort_Grid(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEvent Args)

Dim dv As System.Data.DataView = New System.Data.DataView()
dv=session("dv")
dv.sort=e.SortExpression
datagrid1.datasource=dv

datagrid1.databind
session("dv")=dv


end sub

</script>
<html>
<head>
</head>
<body>
<ASP: Now="Now" ()>
<form runat="server">
<p align="center">
<strong><u>INVENTARIO POR UBICACIÓN</u></strong>&nbsp;&nbsp;&nbsp;
</p>
<p></p>
<p></p>
<p>
Ubicación:&nbsp;<asp:DropDownList id="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedInde xChanged" AutoPostBack="True"></asp:DropDownList>
&nbsp;
<asp:LinkButton id="btnfirst" onclick="pagerbuttonclick" runat="server" CommandArgument="Primera">Primera Página</asp:LinkButton>
<asp:LinkButton id="btnprev" onclick="pagerbuttonclick" runat="server" CommandArgument="anterior">Página Anterior</asp:LinkButton>
<asp:LinkButton id="btnnex" onclick="pagerbuttonclick" runat="server" CommandArgument="siguiente">Página Siguiente</asp:LinkButton>
<asp:LinkButton id="btnlast" onclick="pagerbuttonclick" runat="server" CommandArgument="ultima">Última Página</asp:LinkButton>
&nbsp;
<asp:DropDownList id="DropDownList2" runat="server" OnSelectedIndexChanged="DropDownList2_SelectedInde xChanged" AutoPostBack="True">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
<asp:ListItem Value="5">5</asp:ListItem>
<asp:ListItem Value="6">6</asp:ListItem>
<asp:ListItem Value="7">7</asp:ListItem>
<asp:ListItem Value="8">8</asp:ListItem>
<asp:ListItem Value="9">9</asp:ListItem>
<asp:ListItem Value="10">10</asp:ListItem>
<asp:ListItem Value="11">11</asp:ListItem>
<asp:ListItem Value="12">12</asp:ListItem>
<asp:ListItem Value="13">13</asp:ListItem>
<asp:ListItem Value="14">14</asp:ListItem>
<asp:ListItem Value="15">15</asp:ListItem>
<asp:ListItem Value="16">16</asp:ListItem>
<asp:ListItem Value="17">17</asp:ListItem>
<asp:ListItem Value="18">18</asp:ListItem>
<asp:ListItem Value="19">19</asp:ListItem>
<asp:ListItem Value="20">20</asp:ListItem>
<asp:ListItem Value="21">21</asp:ListItem>
<asp:ListItem Value="22">22</asp:ListItem>
<asp:ListItem Value="23">23</asp:ListItem>
<asp:ListItem Value="24">24</asp:ListItem>
<asp:ListItem Value="25">25</asp:ListItem>
<asp:ListItem Value="26">26</asp:ListItem>
<asp:ListItem Value="27">27</asp:ListItem>
<asp:ListItem Value="28">28</asp:ListItem>
<asp:ListItem Value="29">29</asp:ListItem>
<asp:ListItem Value="30">30</asp:ListItem>
</asp:DropDownList>
</p>
<p>
<asp:DataGrid id="DataGrid1" runat="server" AllowSorting="True" OnSortCommand="Sort_Grid" SelectedIndex="1" Font-Size="Smaller" onpageindexchanged="mi_cambio" AllowPaging="True" PageSize="15">
<HeaderStyle font-size="Larger" horizontalalign="Center" forecolor="Gray" verticalalign="Middle" backcolor="Thistle"></HeaderStyle>
<PagerStyle backcolor="Silver" pagebuttoncount="15" mode="NumericPages"></PagerStyle>
<ItemStyle backcolor="MistyRose"></ItemStyle>
<Columns>
<asp:BoundColumn SortExpression="datos"></asp:BoundColumn>
</Columns>
</asp:DataGrid>
&nbsp;&nbsp;<asp:TextBox id="TextBox1" runat="server" Visible="False"></asp:TextBox>
<asp:Button id="Button1" runat="server" Visible="False" Text="Button"></asp:Button>
&nbsp;&nbsp;&nbsp;
</p>
</form>
</ASP:>
</body>
</html>