2009-11-17 64 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"];