错误:不支持指定的方法?
当我尝试调用 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];
}
}
编辑:
从另一个表单调用 findText 方法时收到该错误,但是从主表单调用此方法不会导致此类错误。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(3)
它支持什么操作取决于底层数据源。我相信
DataTable
是唯一一个开箱即用支持这一点的。您可以通过以下方式检查(在本例中):So;底层数据源是什么?
List
(甚至BindingList
)不会提供此功能。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:So; what is the underlying data source? A
List<T>
(or evenBindingList<T>
) won't provide this.我的 Asp.Net Core API 中出现此错误。这是因为 Asp.Net Framework 和 .Net Core 中的 API 差异。我的应用程序位于 Asp.Net Framework 中,我已将其迁移到 .Net Core。下面的代码在编译时总是可以正常工作,但是在运行时失败并抛出错误
System.NotSupportedException: '不支持指定的方法。'
要解决这个问题,您所要做的就是按照下面的正确方式进行更改。
bodyData = wait new StreamReader(Request.Body, Encoding.Default).ReadToEndAsync();
您还应该添加
System.Text
命名空间。希望有帮助。
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.'
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.
尝试在 Startup.cs 中使用它
app.Use((context, next) =>{context.Request.EnableBuffering();return next();});
Try using it in Startup.cs
app.Use((context, next) =>{context.Request.EnableBuffering();return next();});