Error: Specified method is not supported?
Asked Answered
M

3

11

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.

Machzor answered 11/3, 2010 at 4:53 Comment(1)
Sorry but I didn't understand your question. Please refer to my edit.Machzor
C
5

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.

Christinchristina answered 11/3, 2010 at 4:57 Comment(0)
U
4

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.

Untenable answered 7/6, 2019 at 7:15 Comment(1)
I had this problem too. Tried for 2.5 hours to read the body of the request, nothing worked. I don't understand why it is this the only way.Brumfield
B
0

Try using it in Startup.cs

app.Use((context, next) =>{context.Request.EnableBuffering();return next();});

Bord answered 5/1, 2023 at 2:59 Comment(1)
This doesn't seem to have anything to do with the question, which is related to the implementation of BindingSource.Find.Sabadell

© 2022 - 2024 — McMap. All rights reserved.