开发者

Error: Specified method is not supported?

开发者 https://www.devze.com 2022-12-22 09:14 出处:网络
I keep getting this error when I try to call Find() public void findTxt(string text) { BindingSource src = new BindingSource();

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.


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();

Error: Specified method is not supported?

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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号