- using System;
- using System.Collections;
- using System.Configuration;
- using System.Data;
- using System.Linq;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.HtmlControls;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Xml.Linq;
- using System.Collections.Generic;
- public partial class Default3 : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- List<Person> list = new List<Person> {
- new Person(){Id=1,Name="小明'\"}[]{><,\\/~、\r\n"},
- new Person(){Id=2,Name="小华"}
- };
- DataTable dt = new DataTable("MatrixInfo");
- DataColumn dc1 = new DataColumn("ID");
- DataColumn dc2 = new DataColumn("Name");
- dt.Columns.Add(dc1);
- dt.Columns.Add(dc2);
- foreach (Person p in list)
- {
- DataRow dr = dt.NewRow();
- dr["ID"] = p.Id;
- dr["Name"] = p.Name;
- dt.Rows.Add(dr);
- }
- DataTable dv = dt.DefaultView.ToTable(false, new string[] { "Name" });
- }
- public class Person
- {
- public int Id { get; set; }
- public string Name { get; set; }
- }
- }
转载于:https://www.cnblogs.com/just09161018/p/4605483.html