数组类不能渲染到数据网格中

时间:2009-12-03 17:57:51

标签: c# .net arrays class

以下应用程序不会将我从Web服务返回的信息呈现到数据网格中。我知道我能够连接到web服务,因为我得到了类数组的计数。我能够获得一个Response.Write,但是当我尝试从数组类中提取所有信息时,我无法看到元素,也无法将整个类呈现到数据网格中。可能是我的问题?我坚持这个。

void LoadABCPhoneInfo()
{

    PhoneTypeInfo[] PhoneInfo = GetPhoneInfo();

    DataSet quoteDataSet = XmlString2DataSet(PhoneInfo.ToString());

    //Here is NOT doing the databinding.    
    grdABC.DataSource = quoteDataSet;
    grdABC.DataBind();
    grdABC.Visible = true;
}

private PhoneTypeInfo[] GetPhoneInfo()
{
    //string strGetPhoneInfo = String.Empty;
    PhoneTypeInfo[] strGetPhoneInfo; //

    try
    {
        OwnerAndReservation ownerAndReservationWS = new OwnerAndReservation();

        strGetPhoneInfo = ownerAndReservationWS.GetPhoneTypes();
        //GetPhoneTypesAsync()
        //Here I can get the count for the array
        Response.Write("GetPhoneInfo Length "+ strGetPhoneInfo);
    }
    catch (Exception ex)
    {
        //raise the error
        string errorMessage = String.Format("Error while trying to connect to the Web Service. {0}", ex.Message);
        throw new Exception(errorMessage);

    }
    //return the quote information
    return strGetPhoneInfo;
}


private DataSet XmlString2DataSet(string xmlString)
{
    //create a new DataSet that will hold our values
    DataSet quoteDataSet = null;

    //check if the xmlString is not blank
    if (String.IsNullOrEmpty(xmlString))
    {
        //stop the processing
        return quoteDataSet;

    }

    try
    {
        //create a StringReader object to read our xml string
        using (StringReader stringReader = new StringReader(xmlString))
        {
            //initialize our DataSet
            quoteDataSet = new DataSet();

            //load the StringReader to our DataSet
            quoteDataSet.ReadXml(stringReader);
        }
    }
    catch
    {
        //return null
        quoteDataSet = null;
    }

    //return the DataSet containing the stock information
    return quoteDataSet;
}

0 个答案:

没有答案