2009-11-17 65 views
0

enter code here嗨。我試圖在datalist控件中實現自定義分頁。 和我正在使用Pagedatasource來實現這一個頁面數據源頁面數據源objPage = new PagedDataSource();無法計算未實施ICollection的數據源的計數

try 
{ 

datatable ds= (datatable)viewstate["dtimages"] 
objPage.AllowPaging = true;  
//Assigning the datasource to the 'objPage' object. 
objPage.DataSource = ds.Dataset.Tables["Gallery"].ToString(); 
//Setting the Pagesize 
objPage.PageSize = 8; 
dlGallery.DataSource = objPage; 
dlGallery.DataKeyField = "Image_ID"; 
**dlGallery.DataBind();// getting error** 
} 

catch(Exception ex) 
{ 
throw ex; 
} 

無法計算未實現ICollection的數據源的計數。

爲什麼會這樣沒有任何一個能幫助我 謝謝

+1

ds.Dataset.Tables [ 「圖庫」]的ToString();?。應該是ds.Dataset.Tables [「Gallery」]; – 2009-11-17 13:54:26

回答

1

你設置你的數據源爲一個字符串通過調用toString()方法。

它應該是:

objPage.DataSource = ds.Dataset.Tables["Gallery"];