现在有类using System;
using System.Collections.Generic;
using System.Text;
using System.Data;namespace test
{
public class Class1
{
private string _test;
private int _able;
private float _test2;
private string _test3;
private string _test4;
private string _test5;
private double _test6; public string test4
{
get { return _test4; }
set { _test4 = value; }
} public string test5
{
get { return _test5; }
set { _test5 = value; }
} public double test6
{
get { return _test6; }
set { _test6 = value; }
} public string test
{
get { return _test; }
set { _test = value; }
} public int able
{
get { return _able; }
set { _able = value; }
} public float test2
{
get { return _test2; }
set { _test2 = value; }
} public string test3
{
get { return _test3; }
set { _test3 = value; }
}
}
}
这样的类有很多个,请问怎样将里面的属性获取出来显示在页面上(ASP.NET),并能够编辑这些属性,点击某一属性时显示属性的说明,类似WINFROM中PropertyGrid这样的东西
做过这样东西的人给点思路,谢谢!
using System.Collections.Generic;
using System.Text;
using System.Data;namespace test
{
public class Class1
{
private string _test;
private int _able;
private float _test2;
private string _test3;
private string _test4;
private string _test5;
private double _test6; public string test4
{
get { return _test4; }
set { _test4 = value; }
} public string test5
{
get { return _test5; }
set { _test5 = value; }
} public double test6
{
get { return _test6; }
set { _test6 = value; }
} public string test
{
get { return _test; }
set { _test = value; }
} public int able
{
get { return _able; }
set { _able = value; }
} public float test2
{
get { return _test2; }
set { _test2 = value; }
} public string test3
{
get { return _test3; }
set { _test3 = value; }
}
}
}
这样的类有很多个,请问怎样将里面的属性获取出来显示在页面上(ASP.NET),并能够编辑这些属性,点击某一属性时显示属性的说明,类似WINFROM中PropertyGrid这样的东西
做过这样东西的人给点思路,谢谢!
public string test3
{
get { return _test3; }
set { _test3 = value; }
}
public string test3
{
get { return _test3; }
set { _test3 = value; }
}
{
private string _test;
private int _able;
private float _test2;
private string _test3;
private string _test4;
private string _test5;
private double _test6; public string test4
{
get { return _test4; }
set { _test4 = value; }
}
public string test5
{
get { return _test5; }
set { _test5 = value; }
}
public double test6
{
get { return _test6; }
set { _test6 = value; }
}
public string test
{
get { return _test; }
set { _test = value; }
}
public int able
{
get { return _able; }
set { _able = value; }
}
public float test2
{
get { return _test2; }
set { _test2 = value; }
}
public string test3
{
get { return _test3; }
set { _test3 = value; }
}
}
protected void Page_Load(object sender, EventArgs e)
{
Class1 obj = new Class1();
System.Type type = obj.GetType();
PropertyInfo[] piPublicArray = type.GetProperties();
Response.Write("<b>类名:"+ type.Name+"</b><br>");
Response.Write("共有" + piPublicArray.Length + "个公有属性");
foreach (PropertyInfo pi in piPublicArray)
{
object val = pi.GetValue(obj, null);
Response.Write("<li>"+pi.Name + " 值:"+ (val==null?"null":val.ToString()) +"</li>");
} FieldInfo[] piNonpublicArray = type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic);
Response.Write("<br>共有" + piNonpublicArray.Length + "个非公有字段");
foreach (FieldInfo fi in piNonpublicArray)
{
object val = fi.GetValue(obj);
Response.Write("<li>" + fi.Name + " 值:"+ (val==null?"null":val.ToString())+ "</li>");
}
}
cs文件好像可以直接NEW出来