Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    Recuperare un valore di un Dataset

    Ragazzi ho una sub che mi scaturisce dal click di un pulsante piiù p meno di questo tipo(la scrivo corta perchè è lunghissima,è una query dinamica:
    codice:
    Sub Ricerca(ByVal sender As Object, ByVal e As System.EventArgs)
            Try
    
    
                Dim Conn As New Data.OleDb.OleDbConnection _
                (System.Configuration.ConfigurationManager.AppSettings("ConnectionString").Replace("~", Server.MapPath("")))
                Dim MyDA As Data.OleDb.OleDbDataAdapter
                Dim MyDS As DataSet
    
                Dim nome, data_in, data_out, prodotto, esito As String
                Dim MySQL, txtSQL As String
    MySQL = "SELECT *FROM tab_assistenze WHERE " & txtSQL
                Conn.Open()
                MyDA = New Data.OleDb.OleDbDataAdapter(MySQL, Conn)
                MyDS = New DataSet
                MyDA.Fill(MyDS, "tab_assistenze")
    
    
                Binda()
    
                Conn.Close()
    La Sub binda è questa:
    codice:
    Sub Binda()
            DgrArchivio.DataSource = MyDS
            DgrArchivio.DataMember = "tab_assistenze"
            DgrArchivio.DataBind()
    
        End Sub
    Però non mi mostra il datagrid, credo perchè il dataset lo vede vuoto...
    Come posso fare per recuperare il valore del MyDS che scaturisce dal click del pulsante?

  2. #2
    Be puoi cachare il Dataset.

    codice:
    Dim myDs as New Dataset
    ... ... code for populate Dataset
    Cache("Dataset") = myDs
    
    ... ... Binda()
    If Not Cache("Dataset") Is Nothing Then
         myDs = Cache("Dataset")
    EndIf
    oppure puoi usare la Session ma per oggetti come la Dataset io consiglio vivamente l' uso della Cache.

  3. #3
    Funziona, ma ho unpiccolo problema.
    Il datagrid che devo caricare ha anche il pulsante di editmode, che però non funziona...

    codice:
    Sub Binda()
            If Not Cache("Dataset") Is Nothing Then
                MyDS = Cache("Dataset")
            End If
            DgrArchivio.DataSource = MyDS
            DgrArchivio.DataMember = "tab_assistenze"
            DgrArchivio.DataBind()
    
        End Sub
    
    'QUESTA E' LA SUB DELL'EDIT MODE
        Sub EditDgrArchivio(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
            DgrArchivio.EditItemIndex = e.Item.ItemIndex
            Binda()
    
        End Sub
    Quando clicco sul pulsante di edit mode non mi porta i valori nei campi di testo...
    Come mai?
    Grazie

  4. #4
    Sono un fesso...
    non li mostravo nel bound column, ma nell'item template...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.