Kobinath Ram

Kobinath Ram

  • NA
  • 130
  • 0

XML image how to display at data grid columns in c#.net

Oct 19 2017 11:57 PM
this the xml code this the image i have to display datagridview colums //cdn.apixu.com/weather/64x64/day/113.png
<root>
<condition>
<text>Sunny</text>
<icon>//cdn.apixu.com/weather/64x64/day/113.png</icon>
<code>1000</code>
</condition>
</root>
this is the code I have tried in c#.net. all data will display correctly but image is not displaying the only path is displaying at the datagridview.how to display the image at datgridview
DataTable dt = new DataTable();
dt.Columns.Add("country", typeof(string));
dt.Columns.Add("Date", typeof(string));
dt.Columns.Add("Max Temp", typeof(string));
dt.Columns.Add("Min Temp", typeof(string));
dt.Columns.Add("Text", typeof(string));
dt.Columns.Add("Icon", typeof(string));
city = txttext.Text;
string uri = string.Format("http://api.apixu.com/v1/forecast.xml?={0}&days=7", city);
XDocument doc = XDocument.Load(uri);
foreach (var npc in doc.Descendants("forecastday"))
{
dt.Rows.Add(new object[] {
(string)doc.Descendants("country").FirstOrDefault(),
(string)npc.Descendants("date").FirstOrDefault(),
(string)npc.Descendants("maxtemp_c").FirstOrDefault(),
(string)npc.Descendants("mintemp_c").FirstOrDefault(),
(string)npc.Descendants("text").FirstOrDefault(),
"http:" +(string)npc.Descendants( "icon").FirstOrDefault()
});
}
dataGridView1.DataSource = dt;

Answers (1)