Domanda

Continuo a ricevere questo errore quando provo a chiamare Trova ()

public void findTxt(string text)
    {
        BindingSource src = new BindingSource();
        src.DataSource = dataGridView1.DataSource;
        src.Position = src.Find("p_Name", text);    // Specified method is not supported

        if (src.Position == 0 && dataGridView1.Rows[0].Cells[2].Value.ToString() == text)
        {
            MessageBox.Show("Item found!!");
            dataGridView1.CurrentCell = dataGridView1.Rows[src.Position].Cells[2];
        }
        else if (src.Position == 0 && dataGridView1.Rows[0].Cells[2].Value.ToString() != text)
        {
            MessageBox.Show("Item not found!!");
        }
        else
        {
            MessageBox.Show("Item found!!");
            dataGridView1.CurrentCell = dataGridView1.Rows[src.Position].Cells[2];
        }

    }

Modifica:

Ottengo questo errore quando si chiama il metodo findText da un'altra forma, tuttavia chiamata a questo metodo dalla maschera principale non si traduca in un simile errore.

È stato utile?

Soluzione

E 'fino al sottostante dei dati source quali operazioni esso supporta. Credo che DataTable è l'unico che out of the box supporta questo. Si potrebbe verificare (in questo caso) tramite:

IBindingListView blv = yourDataSource as IBindingListView;
bool canSearch = blv != null && blv.SupportsSearching;

; qual è l'origine dati sottostante? Un List<T> (o anche BindingList<T>) non sarà fornire questo.

Altri suggerimenti

Ho avuto questo errore nel mio API Asp.Net core. E 'stato a causa della differenza API in Asp.Net Framework .Net e Nucleo. La mia domanda era in Framework Asp.Net e avevo migrato alla Net Nucleo. Il seguente codice funzionerà sempre bene in fase di compilazione, ma questo è stato non riuscendo in fase di esecuzione ed è stato gettando il System.NotSupportedException: 'Specified method is not supported.' errore

Request.Body.Seek(0, SeekOrigin.Begin);
var streamReader = new StreamReader(Request.Body);
bodyData = await streamReader.ReadToEndAsync();

entrare descrizione dell'immagine qui

Per risolvere questo tutto ciò che dovete fare è quello di cambiare nel modo giusto, come di seguito.

bodyData = await new StreamReader(Request.Body, Encoding.Default).ReadToEndAsync();

Si dovrebbe anche aggiungere System.Text namespace.

Speranza che aiuta.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top