当前位置:编程学习 > C#/ASP.NET >>

通过Coolite中store数据源绑定控件的XmlReader方式绑定数据的问题?

通过Coolite中store数据源绑定控件的XmlReader方式绑定数据的问题?

store代码如下:
<ext:Store ID="Store1" runat="server">
            <Proxy>
                <ext:HttpProxy Method="POST" Url="./WebService/GetCustomer.asmx/GetCustomerByCustomerID" />
            </Proxy>
            <Reader>
                <ext:XmlReader ReaderID="CustomerID">
                    <Fields>
                        <ext:RecordField Name="CustomerID" AutoDataBind ="true"   Mapping ="CustomerID" />
                        <ext:RecordField Name="CustomerName" AutoDataBind ="true" Mapping="CustomerName"/>
                        <ext:RecordField Name="Address" AutoDataBind ="true"  Mapping ="Address"/>
                        <ext:RecordField Name="Phone" AutoDataBind ="true" Mapping="Phone" />
                    </Fields>
                </ext:XmlReader>
            </Reader>
            <Listeners>
            </Listeners>
        </ext:Store>
gridpanel绑定代码如下:
<ext:GridPanel ID="GridPanel1" runat="server" StoreID="Store1" Height="500">
            <ColumnModel ID="columnModel1" runat="server">
                <Columns>
                    <ext:Column Header="客户序号" DataIndex="CustomerID">
                    </ext:Column>
                    <ext:Column Header="客户名称" DataIndex="CustomerName">
                    </ext:Column>
                    <ext:Column Header="客户地址" DataIndex="Address">
                    </ext:Column>
                    <ext:Column Header="客户电话" DataIndex="Phone">
                    </ext:Column>
                </Columns>
            </ColumnModel>
        </ext:GridPanel>
Url="./WebService/GetCustomer.asmx/GetCustomerByCustomerID" 通过WebService产生数据源代码如下:
public class GetCustomer : System.Web.Services.WebService
{

    [WebMethod]
    public List<Customer> GetCustomerByCustomerID()
    {



        var ds = new DataSet1TableAdapters.CustomerTableAdapter();

        return (from DataRow rows in ds.GetData().Rows
                select new Customer(Convert.ToInt32(rows["CustomerID"]), rows["CustomerName"].ToString(), rows["Address"].ToString(), Convert.ToInt64(rows["Phone"]))).ToList();

        //var ds =
        //    Utilities.GetDsByTableName("select ProvinceID,ProvinceName from S_Province where Region='" +
        //                               regionName +
        //                               "' order by ProvinceID");
        //return (from DataRow dr in ds.Tables[0].Rows
        //        select new Province(dr["ProvinceID"].ToString(), dr["ProvinceName"].ToString())).ToList();



    }

    public class Customer
    {
        public Customer()
        {

        }
        public Customer(Int32 customerID, string customerName, string address, Int64 phone)
        {
            CustomerID = customerID;
            CustomerName = customerName;
            Address = address;
            Phone = phone;
        }
        public Int32 CustomerID { get; set; }
        public string CustomerName { get; set; }
        public string Address { get; set; }
        public Int64 Phone { get; set; }
    }

}

调试运行后结果出现错误,数据不在gridpanel中展示,而是以弹窗的形式展现:


如此图显示不了话,可以访问:
http://blog.csdn.net/tianyu52592/archive/2011/03/23/6272235.aspx


谢谢!!!
--------------------编程问答-------------------- 竟然没有人回答,还是自己来解决吧:
<ext:XmlReader ReaderID="CustomerID">
  <Fields>
  <ext:RecordField Name="CustomerID" AutoDataBind ="true" Mapping ="CustomerID" />
  <ext:RecordField Name="CustomerName" AutoDataBind ="true" Mapping="CustomerName"/>
  <ext:RecordField Name="Address" AutoDataBind ="true" Mapping ="Address"/>
  <ext:RecordField Name="Phone" AutoDataBind ="true" Mapping="Phone" />
  </Fields>
  </ext:XmlReader>
原来是ReaderID为关键字段
应添加Record=Customer才能找到对应的数据!!!
补充:.NET技术 ,  Web Services
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,