关于XML与GRIDVIEW~
请看这一小段GRIDVIEW绑定的XML
private DataTable GetData()
{
string kk = "D:\\project\\Xmltest\\test.xml ";
//建一个DataTable
DataTable dt = new DataTable();
dt.Columns.Add( "姓名 ", typeof(String));
dt.Columns.Add( "性别 ", typeof(String));
//读取xml
XmlDocument doc = new XmlDocument();
doc.Load(kk);
XmlTextReader xt = new XmlTextReader(kk);
XmlNodeList nodes = doc.SelectNodes( "//Result ");
foreach (XmlNode node in nodes)
{
DataRow row = dt.NewRow();
row[ "姓名 "] = node.ChildNodes[3].ChildNodes[1].InnerText;
row[ "性别 "] = node.ChildNodes[5].ChildNodes[1].InnerText;
dt.Rows.Add(row);
}
return dt;
}
protected void Page_Load(object sender, EventArgs e)
{
GridView1.DataSource = GetData();//绑定Datatable
GridView1.DataBind();
}
直接生成没问题。
如果我想在GRIDVIEW的控件里,比如
<asp:BoundField HeaderText= "身份证号 " DataField= "? "/>
<asp:HyperLinkField HeaderText= "姓名 " DataNavigateUrlFormatString= "? " DataTextField= "? " DataTextFormatString= "? "/>
怎么样才能把身份证和姓名绑进去呢??
------解决方案--------------------呵呵,接分来了。