
13/04/2007, 21:16
|
| | Fecha de Ingreso: agosto-2006 Ubicación: en lima peru
Mensajes: 184
Antigüedad: 18 años, 6 meses Puntos: 0 | |
Re: "para Los Tigres"... Sombrear Registros Del Gridview BUENO YA QUE NO HAY NINGUN TIGRE ENTRE USTEDES AQUI LES ENVIO LA SOLUCION
Código:
¡CODE BEHIND
Imports System.Data.SqlClient
Partial Class _Default
Inherits System.Web.UI.Page
Dim vista As Data.DataView
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Session("pos") = "NO"
gvwEmpleado.PageIndex = 0
gvwEmpleado.DataBind()
While Session("pos") <> "SI"
If gvwEmpleado.PageIndex < gvwEmpleado.PageCount - 1 Then
gvwEmpleado.PageIndex = gvwEmpleado.PageIndex + 1
enlazar(gvwEmpleado, vista)
gvwEmpleado.DataBind()
Else
Exit While
End If
End While
End Sub
Public Sub paginar()
Using con As New SqlConnection _
("data source=.\SQLEXPRESS;INTEGRATED SECURITY=TRUE;database=Northwind")
Using da As New SqlDataAdapter("Select CustomerID,CompanyName,ContactName From Customers", con)
Dim ds As New Data.DataSet
da.Fill(ds, "Clientes")
vista = ds.Tables(0).DefaultView
Cache("Vista") = vista
enlazar(gvwEmpleado, vista)
End Using
End Using
End Sub
Public Sub enlazar(ByVal grd As GridView, ByVal vista As Data.DataView)
vista = Cache("Vista")
grd.DataSource = vista
grd.DataBind()
End Sub
Protected Sub gvwEmpleado_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles gvwEmpleado.PageIndexChanging
gvwEmpleado.PageIndex = e.NewPageIndex
enlazar(gvwEmpleado, vista)
End Sub
Protected Sub gvwEmpleado_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvwEmpleado.RowDataBound
Dim a As Integer
For a = 0 To e.Row.Cells.Count - 1
If UCase(e.Row.Cells(a).Text) = UCase(TextBox1.Text) Then
e.Row.Cells(a).BackColor = Drawing.Color.Blue
Session("pos") = "SI"
End If
Next
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' If Not IsPostBack Then
paginar()
' End If
End Sub
End Class
PAGINA ASPX
Código:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body bgcolor="#0099ff">
<form id="form1" runat="server">
<div>
<div style="text-align: center">
<table style="width: 440px">
<tr>
<td style="width: 100px">
<asp:Label ID="lblTitulo" runat="server" Font-Size="Large" ForeColor="Red" Text="Demo 19: Comando de Seleccion de Varias Filas"
Width="405px"></asp:Label></td>
</tr>
<tr>
<td style="width: 100px">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" /></td>
</tr>
<tr>
<td style="width: 100%">
<asp:GridView ID="gvwEmpleado" runat="server" BackColor="#DEBA84" BorderColor="#DEBA84"
BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2" AllowPaging="True" style="width: 100%">
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
</asp:GridView>
<br />
</td>
</tr>
<tr>
<td style="width: 100px; height: 21px">
<asp:Label ID="lblMensaje" runat="server"></asp:Label></td>
</tr>
</table>
</div>
</div>
</form>
</body>
</html>
|