Foros del Web » Programación para mayores de 30 ;) » .NET »

URGENTE como operar la propiedad pagesize del datagrid a traves de un dropdownlist

Estas en el tema de URGENTE como operar la propiedad pagesize del datagrid a traves de un dropdownlist en el foro de .NET en Foros del Web. hola necesito operar la propiedad pagesize del datagrid a traves de un dropdownlist para que haci el usuario pueda definir cuantos datos quiere ver por ...
  #1 (permalink)  
Antiguo 01/03/2005, 12:52
 
Fecha de Ingreso: marzo-2005
Mensajes: 190
Antigüedad: 19 años, 2 meses
Puntos: 0
Exclamación URGENTE como operar la propiedad pagesize del datagrid a traves de un dropdownlist

hola necesito operar la propiedad pagesize del datagrid a traves de un dropdownlist para que haci el usuario pueda definir cuantos datos quiere ver por pagina

el codigo que estoy utilizando es el sgte

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

' Insert page code here


Function MyQueryMethod(ByVal ubicacion As String) As System.Data.DataSet
Dim connectionString As String = "server=xxxxxxxxxx; user id='xx'; password=''; database=xxxx
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(cstr(textbox1.t ext))
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(cstr(textbox1. text))
datagrid1.datasource=myquerymethod(DropDownList1.S electedItem.Text())
datagrid1.databind
end sub



Function MyQueryMethod2() As System.Data.DataSet
Dim connectionString As String = "server=xxxxxxxxxx; user id='xxxx'; password=''; database=xxxxxxx
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 DropDownList2_SelectedIndexChanged(sender As Object, e As EventArgs)
datagrid1.datasource=myquerymethod(dropdownlist2.i tems(datagrid1.pagesize).text)
datagrid1.databind()
End Sub

sub page_load2(sender as object, e as eventargs)
if not page.ispostback then
dropdownlist2.datatextfield = datagrid1.pagesize
'dropdownlist2.datasource=myquerymethod()
dropdownlist2.databind()
end if
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:TextBox id="TextBox1" runat="server" Visible="False"></asp:TextBox>
<asp:Button id="Button1" runat="server" Visible="False" Text="Button"></asp:Button>
</p>
<p>
<asp:DataGrid id="DataGrid1" runat="server" 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>
</asp:DataGrid>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:DropDownList id="DropDownList2" runat="server" OnSelectedIndexChanged="DropDownList2_SelectedInde xChanged" AutoPostBack="True">
<asp:ListItem Value="0">1</asp:ListItem>
<asp:ListItem Value="1">2</asp:ListItem>
<asp:ListItem Value="2">3</asp:ListItem>
<asp:ListItem Value="3">4</asp:ListItem>
<asp:ListItem Value="4">5</asp:ListItem>
<asp:ListItem Value="5">6</asp:ListItem>
<asp:ListItem Value="6">7</asp:ListItem>
<asp:ListItem Value="7">8</asp:ListItem>
<asp:ListItem Value="8">9</asp:ListItem>
<asp:ListItem Value="9">10</asp:ListItem>
<asp:ListItem Value="10">11</asp:ListItem>
<asp:ListItem Value="11">12</asp:ListItem>
<asp:ListItem Value="12">13</asp:ListItem>
<asp:ListItem Value="13">14</asp:ListItem>
<asp:ListItem Value="14">15</asp:ListItem>
<asp:ListItem Value="15">16</asp:ListItem>
<asp:ListItem Value="16">17</asp:ListItem>
<asp:ListItem Value="17">18</asp:ListItem>
<asp:ListItem Value="18">19</asp:ListItem>
<asp:ListItem Value="19">20</asp:ListItem>
<asp:ListItem Value="20">21</asp:ListItem>
<asp:ListItem Value="21">22</asp:ListItem>
<asp:ListItem Value="22">23</asp:ListItem>
<asp:ListItem Value="23">24</asp:ListItem>
<asp:ListItem Value="24">25</asp:ListItem>
<asp:ListItem Value="25">26</asp:ListItem>
<asp:ListItem Value="26">27</asp:ListItem>
<asp:ListItem Value="27">28</asp:ListItem>
<asp:ListItem Value="28">29</asp:ListItem>
<asp:ListItem Value="29">30</asp:ListItem>
</asp:DropDownList>
</p>
</form>
</ASP:>
</body>
</html>
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 03:54.