I want to display the upcoming week's weather information on datagridview. I successfully added the weather api. It will display all records successfully. The only the problem is the image is not displaying in the datagrid. Please help me resolve this problem.
How can I display the image within the datagridview. Below is the code I have developed so far.
This the code for the image:
(string)npc.Descendants("http" + "icon").FirstOrDefault()
This is the rest.
private void button2_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
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));
string city = "london";
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)npc.Descendants("date").FirstOrDefault(),
(string)npc.Descendants("maxtemp_c").FirstOrDefault(),
(string)npc.Descendants("mintemp_c").FirstOrDefault(),
(string)npc.Descendants("text").FirstOrDefault(),
(string)npc.Descendants("http" + "icon").FirstOrDefault()
});
}
dataGridView1.DataSource = dt;
// getW(txttext.Text);
}
}
}