建议 你使用ArrayList 帮定
例如 IList list = new ArrayList();
list.Add("对象");
例如 IList list = new ArrayList();
list.Add("对象");
解决方案 »
- c# Winform 如何刷新数据
- 庆祝在java\asp\asp.net间登录时的md5问题解决,散分
- 怎么将一个数字按输入的值平均分配
- 如何在用户控件中调用页面上的方法?
- iframe显示数据库的内容。要么只有图片。要么只有文字???
- gridview中嵌入checkbox的问题
- DatList的模版中添加控件问题
- SMTP发送邮件问题~~~请高手指教!
- FormsAuthentication.RedirectFromLoginPage的奇怪问题
- 关于分页,为什么不能由数据库实现,而必须让程序员编写复杂的程序实现?
- asp.net 中怎样实现session 在URL中传送呀。。。
- CustomValidator 的客户端验证 问题
数据全部显示出来了。。当然列的顺序也对。刚好和 我数据库中列的 顺序相对应。。但是取值的时候,比如说在 datagridview 中
this.datagridview.currentrow.cell[0].value . 他可能得到的 不是 第一列的值。。然后 我让他 自动生成列。。发现 列的顺序 也没有规则我设置 断点 调试 :
this.dataGridView1.DataSource = P.ShowProductInfo()运行到 这个地方的时候。。程序 跳转到了 类中
public int Pid
{
get { return this._Pid; }
set { this._Pid = value; }
}
public string Pname
{
get { return this._Pname; }
set { this._Pname = value; }
}
public DateTime Pdate
{
get { return this._Pdate; }
set { this._Pdate = value; }
}执行了 public DateTime Pdate 真是 奇怪啊。举了 好几个例子 都是这样的。
...DataBind();
老兄这个是怎么绑定的,我怎么也显示不了
<Columns>
<asp:BoundField DataField="userId" HeaderText="userId" />
<asp:BoundField DataField="userName" HeaderText="userName" />
</Columns>
</asp:GridView>这里面的字段写什么?
GovUser[] govUserList = (GovUser[])sSearchResult.List;
if (govUserList != null)
{ for (int i = 0; i < govUserList.Length; i++)
{
GovUser govUser = govUserList[i];
string userId = govUser.userId;
}
}
dataGridView1.DataSource = govUserList;老兄,你是怎么绑定的,我怎么无法显示的
dataGridView1.DataSource = govUserList; dataGridView1.DataBind() 你是忘了写。还是?
=====================SearchResult sSearchResult = sIMetaManger.GetGovUserListQuery(query);
GovUser[] govUserList = (GovUser[])sSearchResult.List;
if (govUserList != null)
{ for (int i = 0; i < govUserList.Length; i++)
{
GovUser govUser = govUserList[i];
string userId = govUser.userId;
}
}
dataGridView1.DataSource = govUserList;
===========看不懂你是怎么 写的
原创: Ankoe 前言 Nhibernate 查询数据返回集合为 Ilist 类型,由于 Ilist 实现了 Collection ,所以当 Ilist 绑定到 DataGridView 时,显示的字段并未按真实的顺序排序,造成显示的不适当。可以采用两种解决方法: 方法一:将 Ilist 转换成 DataSet 注: iList: 数据源 className: 类完全限定名 DllFile:className 所属的程序集名 如 :SysGUI.QdcLib.dll public DataSet ConvertIListToDataSet(IListiList, stringclassName, stringDllFile) { Type TheType = null; if (DllFile != "") { Assembly Assembly1 = Assembly.LoadFrom(DllFile); TheType = Assembly1.GetType(className); } else { TheType = Type.GetType(className); } string sTableName = NHibernate.Cfg.ImprovedNamingStrategy.Instance.ClassToTableName(className); BindingFlags bindFlag = BindingFlags.Public | BindingFlags.Instance; PropertyInfo[] pInfos = TheType.GetProperties(bindFlag); DataSet dSet = newDataSet(); DataTable dTable = dSet.Tables.Add(sTableName); string strColmunName =""; foreach (PropertyInfoinfoinpInfos) { strColmunName = NHibernate.Cfg.ImprovedNamingStrategy.Instance.PropertyToColumnName(info.Name); dTable.Columns.Add(strColmunName, info.PropertyType.GetType()); } foreach(objectobjiniList){ DataRow dRow = dTable.NewRow(); foreach(PropertyInfoinfoinpInfos){ strColmunName = NHibernate.Cfg.ImprovedNamingStrategy.Instance.PropertyToColumnName(info.Name); dRow[strColmunName] = info.GetValue(obj, null); } dTable.Rows.Add(dRow); } return dSet; } 上面采用反射根据属性名及类型信息生成一个DataTable,然后用Ilist数据填充DataTable,这种方法有个不好的地方就是如果数据量大的时候,严重造成了程序的性能损失。 方法二:建一个表来保存所有表的字段信息,DataGridView加载Ilist数据以后再改变DataGirdView的显示方式。和方法一相比少了数据得制,性能也得以提升。