代码如下:DataSet ds = new DataSet();
ds.ReadXml(Application.StartupPath+"\\XMLFile.xml");
dataGridView1.AutoGenerateColumns = true;
dataGridView1.DataSource = ds;
dataGridView1.DataMember = "family";
xml文件如下
<?xml version="1.0" encoding="utf-8" ?>
<Boot>
<server>
<family>
<name>xxx1</name>
<tc>001</tc>
<tp>123.jpg</tp>
</family>
<family>
<name>xxx2</name>
<tc>002</tc>
<tp>123.jpg</tp>
</family>
</server>
</Boot>
现在是能显示 <family> 里的数据 但是我想要最后一项 以图片出现 不是现在绑定的文字 该怎么做呢 请高手 指教 谢谢
ds.ReadXml(Application.StartupPath+"\\XMLFile.xml");
dataGridView1.AutoGenerateColumns = true;
dataGridView1.DataSource = ds;
dataGridView1.DataMember = "family";
xml文件如下
<?xml version="1.0" encoding="utf-8" ?>
<Boot>
<server>
<family>
<name>xxx1</name>
<tc>001</tc>
<tp>123.jpg</tp>
</family>
<family>
<name>xxx2</name>
<tc>002</tc>
<tp>123.jpg</tp>
</family>
</server>
</Boot>
现在是能显示 <family> 里的数据 但是我想要最后一项 以图片出现 不是现在绑定的文字 该怎么做呢 请高手 指教 谢谢
+1
直接绑就当文字了,加个控件绑上图片 picBox.Image = Image.LoadFrom(完整路径);
BorderColor="Tan" BorderWidth="1px" CellPadding="2" ForeColor="Black" GridLines="None"
Width="1192px">
<Columns>
<asp:TemplateField HeaderText="图片">
<ItemTemplate>
<asp:Image ID="image1" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "ID")%>'/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="Tan" />
<PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
<HeaderStyle BackColor="Tan" Font-Bold="True" />
<AlternatingRowStyle BackColor="PaleGoldenrod" />
</asp:GridView>其余的不解释了
BorderColor="Tan" BorderWidth="1px" CellPadding="2" ForeColor="Black" GridLines="None"
Width="1192px">
<Columns>
<asp:TemplateField HeaderText="图片">
<ItemTemplate>
<asp:Image ID="image1" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "ID")%>'/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="Tan" />
<PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
<HeaderStyle BackColor="Tan" Font-Bold="True" />
<AlternatingRowStyle BackColor="PaleGoldenrod" />
</asp:GridView>