Question : Count records in dataset

Hi
Trying to count how many records are in a dataset, but keep getting the same total which is 1, which i assume is the number of tables not rows.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
protected void btnWeatherLocation_Click(object sender, EventArgs e)
    {
        strCityName = txtWeatherLocation.Text.ToString();
        string strWeatherURL = "http://xoap.weather.com/search/search?where=" + strCityName.ToString();
        System.Data.DataSet dsWeather = new System.Data.DataSet();
        XmlReader xmlWeatherReader = XmlReader.Create(strWeatherURL);
        dsWeather.ReadXml(xmlWeatherReader);
        if (xmlWeatherReader.EOF == true)
        {
            Response.Write("No Location");
            WeatherRepeater.Visible = false;
        }
        else
        {
            strNumberOfResults = dsWeather.Tables[0].Rows.Count;
            litRecordCount.Text = "Found: " + strNumberOfResults.ToString() + " matches
"; WeatherRepeater.Visible = true; GridView1.DataMember = "loc"; GridView1.DataSource = dsWeather; GridView1.DataBind(); WeatherRepeater.DataMember = "loc"; WeatherRepeater.DataSource = dsWeather; WeatherRepeater.DataBind(); } } ----------------------------------------- /////////////////////////////////////
<%# Eval("loc_text")%>

Answer : Count records in dataset

I'd suggest using:
   dsWeather.Tables["loc"].Rows.Count

It looks like the dataset has two tables, "search" and "loc". I'm guessing "loc" is the one you are intested in.
Random Solutions  
 
programming4us programming4us