Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Specified method is not supported?

I keep getting this error when I try to call Find()

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];
        }

    }

Edit:

I get that error when calling findText method from another form, However calling this method from the main form doesn't result in such an error.

like image 834
DanSogaard Avatar asked Mar 11 '10 04:03

DanSogaard


2 Answers

It is up to the underlying data-source what operations it supports. I believe that DataTable is the only one that out of the box supports this. You could check (in this case) via:

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

So; what is the underlying data source? A List<T> (or even BindingList<T>) won't provide this.

like image 158
Marc Gravell Avatar answered Oct 15 '22 19:10

Marc Gravell


I had this error in my Asp.Net Core API. It was because of the the API difference in Asp.Net Framework and .Net Core. My application was in Asp.Net Framework and I had migrated it to the .Net Core. The below code will always work fine in the compile time, but this was failing at the run time and was throwing the error System.NotSupportedException: 'Specified method is not supported.'

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

enter image description here

To fix this all you have to do is to change it in the right way as below.

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

You should also add System.Text namespace.

Hope it helps.

like image 40
Sibeesh Venu Avatar answered Oct 15 '22 19:10

Sibeesh Venu