![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
04/04/2007, 14:36
|
| | Fecha de Ingreso: agosto-2006 Ubicación: en lima peru
Mensajes: 184
Antigüedad: 18 años, 5 meses Puntos: 0 | |
Esto No Funciona ESTO NO FUNCIONA SI ES QUE NO VUELVES A ENLAZAR EL DATASOURCE DEL GRIDVIEW CON LA FUENTE DE DATOS
UMMMMMMM
AQUI VA EL CODIGO
Código:
Imports System.Data.SqlClient
Partial Class _Default
Inherits System.Web.UI.Page
Dim ds As New Data.DataSet
Dim dS1 As New Data.DataSet
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
dS1 = Session("categoria")
Dim dr As Data.DataRow = dS1.Tables("categoria").NewRow
dr("Categoryname") = TextBox1.Text
dr("Description") = TextBox2.Text
dS1.Tables("categoria").Rows.Add(dr)
'da.Tables(0).Columns("CategoryId").
GridView1.DataSource = dS1.Tables("categoria").DefaultView
GridView1.DataBind()
End Sub
Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load
If Not IsPostBack Then
Dim cn As New SqlConnection("integrated security=true;data source=.\SQLEXPRESS;initial catalog=northwind")
Dim da As New SqlDataAdapter("select * from categories", cn)
da.Fill(ds, "categoria")
GridView1.DataSource = ds.Tables(0)
GridView1.DataBind()
Session("categoria") = ds
End If
End Sub
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
With GridView1
dS1 = Session("categoria")
Dim a As Integer = .SelectedRow.RowIndex
dS1.Tables(0).Rows(a).Delete()
dS1.AcceptChanges()
.DataSource = dS1.Tables(0)
.DataBind()
End With
End Sub
Sub CustomersGridView_PageIndexChanging(ByVal sender As Object, ByVal e As GridViewPageEventArgs) Handles GridView1.PageIndexChanging
'' Cancel the paging operation if the user attempts to navigate
'' to another page while the GridView control is in edit mode.
'If GridView1.EditIndex <> -1 Then
' ' Use the Cancel property to cancel the paging operation.
' e.Cancel = True
' ' Display an error message.
' Dim newPageNumber As Integer = e.NewPageIndex + 1
' lblmensaje.Text = "Please update the record before moving to page " & _
' newPageNumber.ToString() & "."
'Else
' ' Clear the error message.
' lblmensaje.Text = ""
'End If
GridView1.PageIndex = e.NewPageIndex()
dS1 = Session("categoria")
GridView1.DataSource = dS1.Tables(0)
GridView1.DataBind()
End Sub
End Class
|