将simpleDB中的数据放入数据gridview中

时间:2014-06-01 12:03:32

标签: c# asp.net gridview amazon-simpledb

我尝试从Amazon SimpleDB检索数据,目前只显示domainName等文本中的数据:{attribute1,value2} {attribute1,value2}。 如何在数据网格视图中显示数据?我的代码如下:

 public static List<String> GetItemByQuery(IAmazonSimpleDB simpleDBClient, string domainName)
    {
        List<String> Results = new List<String>(); ;
        SelectResponse response = simpleDBClient.Select(new SelectRequest()
        {
            SelectExpression = "Select * from " + domainName
        });
        String res = domainName + " has: ";

        foreach (Item item in response.Items)
        {

            res = item.Name + ": ";
            foreach (Amazon.SimpleDB.Model.Attribute attribute in item.Attributes)
            {
                res += "{" + attribute.Name + ", " + attribute.Value + "}, ";
            }
            res = res.Remove(res.Length - 2);
            Results.Add(res);

        }

        return Results;
    }  

1 个答案:

答案 0 :(得分:0)

你如何阅读:

http://docs.aws.amazon.com/sdkfornet1/latest/apidocs/html/P_Amazon_SimpleDB_Model_SelectResult_Item.htm

您的response.Items

public List<Item> Item { get; set; }

因此您应该直接使用Grid的DataSource,将autogenerate列设置为您的网格以开始查看结果