Kobinath Ram

Kobinath Ram

  • NA
  • 130
  • 0

how to display 7 days of week weather forecast in c#

Oct 11 2017 1:19 AM
I have tried this code many times. below code but getting Error.
this is the API used to get the 7 days week forecast. in below I entered the city "London".so I can get the 7 days forecast report of London.
http://api.apixu.com/v1/forecast.xml?key=5742bec32f4141e08db171907171010&q=london&days=7
when I write the code in c#. instead of London, I passed the one textbox control.because the country which I entered in the textbox.the particular country is 7-day forecast will be displayed at grid view. this is the code I tried
string city = txtcity.Text;
string uri = string.Format("http://api.apixu.com/v1/forecast.xml?key=02d3de968c424e20b5a74149172409 &q=" + city + " &days=7");
I strucked at this point. I don't know how to pass the textbox name within URL.
the final result has to be displayed on the grid view control. I tried the code below. 7 days forecast will have to display on the grid view.
XmlReader xmlFile;
xmlFile = XmlReader.Create(uri);
DataSet ds = new DataSet();
ds.ReadXml(xmlFile);
dataGridView1.DataSource = ds.Tables[1];
please, anyone, help me to solve this problem

Answers (3)