c# 中将数据库中的数据多列合并到DataGridView的一列中 我的数据库中的三列的数据为“A,B,C ”.我想在DataGridView的一列中显示出三列的内容,我用“isnull(t_txt1,'')+isnull(t_txt2,'')+isnull(txt3,'') ”当结果显示为“A B C ”字符中间有很多的空格。请问怎么写才能显示出“ ABC ”啊? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1.第一种,在你的gridview绑定的数据源上面进行处理,把三个列先合成一列,2.在绑定的时候用一个函数来处理<%# GetContent(Eval("绩效1字段"),Eval("字段2"),Eval("字段3")) %> public string GetContent(object o, object o2, object o3) { return o.ToString().Trim() + o2.ToString().Trim() + o3.ToString().Trim(); } select A+B+C from table赋值的时候去空格。 Thank you! Try it now! 各位高手,我是初级,试了一下还是不是很懂,能不能写详细一点!我用的是winform程序!protected string P_str_table = "tb_tool";string P_str_DataView = "select t_name ,isnull(t_location,'')+isnull(t_floor,'')+isnull(t_position,'') from tb_tool";DataSet myds_dgv = boperate.getds(P_str_DataView, P_str_table);DataGridView.DataSource = myds_dgv.Tables[0];但是显示的结果还是:A B C ,中间有空格,能不能把你们说的方法写具体点!谢谢各位高手了! 这个已经很清楚了。select t_name ,ltrim(rtrim(isnull(t_location,'')))+ltrim(rtrim(isnull(t_floor,'')))+ltrim(rtrim(isnull(t_position,''))) from tb_tool winform DataTable数据导入excel Treeview的用法 如何中断程序的运行? load (加载)事件 如何用C#动态生成checkbox 在线等 vb版里无人回答,只好跑c#版了 在主程序中对控件进行操作的过程 改写到类里面,高手赏光来看看 最笨的问题 请帮忙 wcf验证用户登陆 c#连接oracle数据库时执行更新操作无效? 将xml文件里的数据放如自定义类里存入HashTable里面 Gridview是绑定sql server 数据库中的数据快还是绑定XML中的数据快? 怎么编写纯资源Dll,以及如何调用(C#)
1.第一种,在你的gridview绑定的数据源上面进行处理,把三个列先合成一列,2.在绑定的时候用一个函数来处理<%# GetContent(Eval("绩效1字段"),Eval("字段2"),Eval("字段3")) %>
public string GetContent(object o, object o2, object o3)
{
return o.ToString().Trim() + o2.ToString().Trim() + o3.ToString().Trim();
}
赋值的时候去空格。
protected string P_str_table = "tb_tool";
string P_str_DataView = "select t_name ,isnull(t_location,'')+isnull(t_floor,'')+isnull(t_position,'') from tb_tool";
DataSet myds_dgv = boperate.getds(P_str_DataView, P_str_table);
DataGridView.DataSource = myds_dgv.Tables[0];
但是显示的结果还是:A B C ,中间有空格,能不能把你们说的方法写具体点!谢谢各位高手了!
这个已经很清楚了。
select t_name ,ltrim(rtrim(isnull(t_location,'')))+ltrim(rtrim(isnull(t_floor,'')))+ltrim(rtrim(isnull(t_position,''))) from tb_tool