0
protected void BindData()
{
List<Product> products = product.GetRepeaterData(prod);
string json = JsonConvert.SerializeObject(products);
dataRepeater.DataSource = json;
dataRepeater.DataBind();
}
<asp:Repeater ID="dataRepeater" runat="server">
<HeaderTemplate>
List<div id="accordion">
</HeaderTemplate>
<ItemTemplate>
<h3>
<a href="#" style="background-color: gray; height: 25px; color: White; text-decoration: none;">
<%# DataBinder.Eval(Container.DataItem, "Name")%></a></h3>
<div>
<ul>
<li><span>Id:
<%# DataBinder.Eval(Container.DataItem, "Id")%></span></li>
<li><span>OrganizationId:
<%# DataBinder.Eval(Container.DataItem, "Organization")%></span> </li>
<li><span>ParentProduct:
<%# DataBinder.Eval(Container.DataItem, "Product")%></span></li>
</div>
</ItemTemplate>
<FooterTemplate>
</div></FooterTemplate>
</asp:Repeater>
error: DataBinding: 'System.Char' does not contain a property with the name 'Name'.
<%# DataBinder.Eval(Container.DataItem, "Name")%></a></h3>
我是一個新的JSON和Ajax的概念。我們從web服務獲取大量數據,所以它減緩了這個過程,直到調用完成。我必須使用JSON和Ajax進行異步調用。 目前我能夠序列化/反序列化數據之前綁定現在我沒有看到任何點綁定數據反序列化到中繼器後,所以我試圖綁定串行化的數據到中繼器,但它沒有約束力。 其次任何人都可以請告訴我如何做到這一點,作爲ajax電話?在客戶端添加更新面板是否足以達到目的?我很抱歉,我知道這個問題有點含糊,但我失去了右now..any文檔或實例也將幫助..因爲我不知道這是做的正確的方式....將序列化的JSON數據綁定到中繼器
非常感謝...嗯你能指出我在正確的direction..I想我會做到這一點----你通過Ajax調用得到JSON,並使用這些數據來在標記添加到DOM您需要的方式 – Scorpio
這裏是一個體面的例子:http://www.codeproject.com/Articles/211489/Using-JSON-with-ASP-NET-3-5 –