无法对system.int32和system.string执行'='操作 [英] cannot perform '=' operation on system.int32 and system.string
本文介绍了无法对system.int32和system.string执行'='操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
(bond_dataGridView.DataSource as DataTable).DefaultView.RowFilter = string.Format([denom] ='{0}',denom_comboBox.SelectedItem);
它只显示某些数据有限的列的值但是对于长数据它会给出错误帮助我....!
解决方案
所以你为什么不从你的RowFilter表达式中删除单引号:
(bond_dataGridView.DataSource as DataTable).DefaultView.RowFilter =( string .Format( [denom] = {0},denom_comboBox.SelectedItem);
// ^ --- ^
您试图将int
与RowFilter
表达式中的> string ,这是mos可能不是你想要的。
问候,
- 曼弗雷德
首先,您在哪里放置了参数所需的值?
例如:
denom_comboBox.DataSource = YourDataSource;
denom_comboBox.DataValueField = ColID;
denom_comboBox.DataTextField = ColCode;
denom_comboBox.DataBind();
如果你想获得所选的ColID,那么使用
denom_comboBox.selectedValue
如果要获取所选文本ColCode,请使用
denom_comboBox。 selectedItem.Text
如果你想获得所选索引,那么使用
denom_comboBox.selectedIndex
你有没有尝试过
(bond_dataGridView.DataSource as DataTable).DefaultView。 RowFilter =(string.Format([denom] ='{0}',denom_comboBox.SelectedItem .ToString() );
(bond_dataGridView.DataSource as DataTable).DefaultView.RowFilter = string.Format("[denom]= '{0}'", denom_comboBox.SelectedItem);
it only show value for some column where data is limited but for long data it give error help me....!
解决方案
So why don't you just remove the single quotes from your RowFilter expression:
(bond_dataGridView.DataSource as DataTable).DefaultView.RowFilter =(string.Format("[denom] = {0}", denom_comboBox.SelectedItem); // ^---^
You were trying to compare anint
to astring
in yourRowFilter
expression, which is most probably not what you intended.
Regards,
— Manfred
First of all, where did you put the value you need for the parameter?
For example:
denom_comboBox.DataSource = YourDataSource; denom_comboBox.DataValueField = "ColID"; denom_comboBox.DataTextField = "ColCode"; denom_comboBox.DataBind();
If you want to get the selected "ColID" then use
denom_comboBox.selectedValue
If you want to get the selected text "ColCode" then use
denom_comboBox.selectedItem.Text
If you want to get the selected index then use
denom_comboBox.selectedIndex
Did you try
(bond_dataGridView.DataSource as DataTable).DefaultView.RowFilter =(string.Format("[denom]= '{0}'", denom_comboBox.SelectedItem.ToString());
这篇关于无法对system.int32和system.string执行'='操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文