DataView绑定数据不区分大小写

langmafeng 2007-10-31 02:53:38
public class TestView
{
private String m_Test;
public String Test
{
get { return m_Test; }
set { m_Test = value; }
}
private Int32 m_TEST;
public Int32 TEST
{
get { return m_TEST; }
set { m_TEST = value; }
}
}

TestView[] testViews = new TestView[2];
TestView testView = new TestView();
testView.TEST = 1;
testView.Test = "a";
testViews[0] = testView;
testView = new TestView();
testView.TEST = 2;
testView.Test = "b";
testViews[1] = testView;
this.dataGridView1.DataSource = testViews;

运行后的结果居然是这样的:


看来DataGridView绑定数据时内部通过通过反射获取数据时是不区分大小写的
算不算BUG呢?
现在修改类的定义不太可能,这两天还在找解决方案,研究中...
...全文
197 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
fellowcheng 2007-10-31
  • 打赏
  • 举报
回复
Microsoft Visual Studio 2005
版本 8.0.50727.762 (SP.050727-7600)
Microsoft .NET Framework
版本 2.0.50727

已安装的版本: Enterprise

Microsoft Visual Basic 2005 55603-007-4000003-41921
Microsoft Visual Basic 2005

Microsoft Visual C# 2005 55603-007-4000003-41921
Microsoft Visual C# 2005

Microsoft Visual C++ 2005 55603-007-4000003-41921
Microsoft Visual C++ 2005

Microsoft Visual J# 2005 55603-007-4000003-41921
Microsoft Visual J# 2005

Microsoft Visual Studio Tools for Office 55603-007-4000003-41921
Microsoft Visual Studio Tools for the Microsoft Office System

Microsoft Visual Web Developer 2005 55603-007-4000003-41921
Microsoft Visual Web Developer 2005

Microsoft Web Application Projects 2005 55603-007-4000003-41921
Microsoft Web Application Projects 2005
版本 8.0.50727.762

Visual Studio 2005 Team Edition for Architects 55603-007-4000003-41921
Microsoft Visual Studio 2005 Team Edition for Software Architects

Visual Studio 2005 Team Edition for Developers 55603-007-4000003-41921
Microsoft Visual Studio 2005 Team Edition for Software Developers

Visual Studio 2005 Team Edition for Testers 55603-007-4000003-41921
Microsoft Visual Studio 2005 Team Edition for Software Testers

CodeSmith 3.2
CodeSmith Tools Visual Studio Add-in Package

Crystal Reports AAC6G-K0CSA4K-U70001R
Crystal Reports for Visual Studio 2005


Microsoft Visual Studio 2005 Team Suite - 简体中文 Service Pack 1 (KB926604)
此 Service Pack 是用于 Microsoft Visual Studio 2005 Team Suite - 简体中文 的。
如果以后安装较新的 Service Pack,则会自动卸载此 Service Pack。
有关更多信息,请访问 http://support.microsoft.com/kb/926604

我的试过了,和lz一样
jiatong1981 2007-10-31
  • 打赏
  • 举报
回复
我的是TM版本 你的是SP

可能没有比较价值
jiatong1981 2007-10-31
  • 打赏
  • 举报
回复
Microsoft Visual Studio 2005
版本 8.0.50727.42 (RTM.050727-4200)
Microsoft .NET Framework
版本 2.0.50727

已安装的版本: Enterprise

Microsoft Visual C# 2005
Microsoft Visual C# 2005

Microsoft Visual Studio Tools for Office
Microsoft Visual Studio Tools for the Microsoft Office System

Microsoft Visual Web Developer 2005
Microsoft Visual Web Developer 2005

Visual Studio 2005 Team Edition for Architects
Microsoft Visual Studio 2005 Team Edition for Software Architects

Visual Studio 2005 Team Edition for Developers
Microsoft Visual Studio 2005 Team Edition for Software Developers

Visual Studio 2005 Team Edition for Testers
Microsoft Visual Studio 2005 Team Edition for Software Testers

Visual Studio 2005 团队资源管理器
Microsoft Visual Studio 2005 团队资源管理器
版本 8.0.50727.147

Crystal Reports AAC6G-K0CSA4K-U70001R
Crystal Reports for Visual Studio 2005


Extensions for Windows WF
Windows Workflow Foundation Tools for Visual Studio

Orcas Technology Preview - .NET Framework 3.0 Development Tools 1.0
Microsoft Visual Studio Code Name Orcas Community Technology Preview - Development Tools for WinFX

TestTrack Pro Visual Studio .NET Add-In
For more information about Seapine Software, Inc., see the Seapine Software, Inc. website at http://www.seapine.com
For customer support, call 1-888-683-6456.
Copyright (c) 2002 Seapine Software, Inc. Inc.
langmafeng 2007-10-31
  • 打赏
  • 举报
回复
偶现在用的版本是:
Microsoft Visual Studio 2005
Version 8.0.50727.762 (SP.050727-7600)
Microsoft .NET Framework
Version 2.0.50727

Installed Edition: Professional

Microsoft Visual Basic 2005 77626-009-0000007-41343
Microsoft Visual Basic 2005

Microsoft Visual C# 2005 77626-009-0000007-41343
Microsoft Visual C# 2005

Microsoft Visual C++ 2005 77626-009-0000007-41343
Microsoft Visual C++ 2005

Microsoft Visual J# 2005 77626-009-0000007-41343
Microsoft Visual J# 2005

Microsoft Visual Web Developer 2005 77626-009-0000007-41343
Microsoft Visual Web Developer 2005

Microsoft Web Application Projects 2005 77626-009-0000007-41343
Microsoft Web Application Projects 2005
Version 8.0.50727.762

Crystal Reports AAC60-G0CSA4B-V7000AY
Crystal Reports for Visual Studio 2005


Microsoft Visual Studio 2005 Professional Edition - ENU Service Pack 1 (KB926601)
This service pack is for Microsoft Visual Studio 2005 Professional Edition - ENU.
If you later install a more recent service pack, this service pack will be uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/926601

Security Update for Microsoft Visual Studio 2005 Professional Edition - ENU (KB937061)
This Security Update is for Microsoft Visual Studio 2005 Professional Edition - ENU.
If you later install a more recent service pack, this Security Update will be uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/937061

TestTrack Visual Studio .NET Add-In
For more information about Seapine Software, Inc., see the Seapine Software, Inc. website at http://www.seapine.com
For customer support, call 1-888-683-6456.
Copyright (c) 2002 - 2005 Seapine Software, Inc. Inc.
jiatong1981 2007-10-31
  • 打赏
  • 举报
回复
是不是我用的版本已经修正了?

我用的是Microsoft Visual Studio 2005 Team Edition for Software Developers
jiatong1981 2007-10-31
  • 打赏
  • 举报
回复
寒一个
难道你们都有?

其它人都try一下么

反正我这里ok
langmafeng 2007-10-31
  • 打赏
  • 举报
回复
Re 11楼
................
原因很复杂,你的观点不在本帖讨论范围之内
  • 打赏
  • 举报
回复
没做过这样的事情,你为什么要做成这样的呢?你区分了不就行了?
jiatong1981 2007-10-31
  • 打赏
  • 举报
回复
……

为什么我就没有
fellowcheng 2007-10-31
  • 打赏
  • 举报
回复
好象是有这个问题
不过也难免,sqlserver的列就是不分大小写的
langmafeng 2007-10-31
  • 打赏
  • 举报
回复
Re 3楼:DataGridView内部取数据的时候肯定用到了反射
Re 4楼:为了测试方便以及测试结果的准确性,我专门建了一个空的测试项目,代码都帖出来了
hooo 2007-10-31
  • 打赏
  • 举报
回复
竟然不区分大小写。。
看来是bug吧
我去呀 2007-10-31
  • 打赏
  • 举报
回复
按你的方法testViews[0]和testViews[1]指向的是同一个对象
我去呀 2007-10-31
  • 打赏
  • 举报
回复
你写的代码有问题,这样写试试
TestView[] testViews = new TestView[2];
testViews[0].TEST = 1;
testViews[0].Test ="a";
testViews[1].TEST = 2;
testViews[1].Test = "b ";
this.dataGridView1.DataSource = testViews;

jiatong1981 2007-10-31
  • 打赏
  • 举报
回复
…… 肯定是你代码里有问题

不会出现这种bug的

呵呵 应该说这是你的bug
bitsbird 2007-10-31
  • 打赏
  • 举报
回复
哪里有反射?
langmafeng 2007-10-31
  • 打赏
  • 举报
回复
jiatong1981 2007-10-31
  • 打赏
  • 举报
回复
??

你挂的图看不到 但是我这里代码运行出来 没有任何问题

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧