按照icecock的方法写了:运行报错: AllowCustomPaging must be true and VirtualItemCount must be set for a DataGrid with ID DataGrid1 when AllowPaging is set to true and the selected datasource does not implement ICollection. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: AllowCustomPaging must be true and VirtualItemCount must be set for a DataGrid with ID DataGrid1 when AllowPaging is set to true and the selected datasource does not implement ICollection.
Line 118: myConnection.Open(); Line 119: DataGrid1.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection); Line 120: DataGrid1.DataBind(); Line 121: } Line 122: protected string formaturl(object strArgument) Source File: d:\inetpub\wwwroot\webhandphone\addgoods.aspx.cs Line: 120
DataGrid.CurrentPageIndex = e.NewPageIndex;
BindGrid();//用作datagrid的数据绑定用
AllowCustomPaging must be true and VirtualItemCount must be set for a DataGrid with ID DataGrid1 when AllowPaging is set to true and the selected datasource does not implement ICollection.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: AllowCustomPaging must be true and VirtualItemCount must be set for a DataGrid with ID DataGrid1 when AllowPaging is set to true and the selected datasource does not implement ICollection.
Line 119: DataGrid1.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
Line 120: DataGrid1.DataBind();
Line 121: }
Line 122: protected string formaturl(object strArgument)
Source File: d:\inetpub\wwwroot\webhandphone\addgoods.aspx.cs Line: 120
http://dotnet.aspx.cc/ShowDetail.aspx?id=ECD9AE16-8FF0-4A1C-9B9F-5E8B641CB1B1在我的datagrid中绑定显示了图片的
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
SqlDataAdapter da=new SqlDataAdapter("select * from gj_lb_zd",con);
DataSet ds = new DataSet();
da.Fill(ds,"gj_lb_zd");
DataGrid1.DataSource=ds.Tables["gj_lb_zd"].DefaultView;
DataGrid1.CurrentPageIndex=e.NewPageIndex;
DataGrid1.DataBind();
}
<asp:TemplateColumn HeaderText="图片">
<HeaderStyle Wrap="False" HorizontalAlign="Center" VerticalAlign="Middle"></HeaderStyle>
<ItemStyle Wrap="False" HorizontalAlign="Center" VerticalAlign="Middle"></ItemStyle>
<ItemTemplate>
<asp:Image id=Image1 runat="server" Height=30 Width=30 ImageUrl='<%# formaturl(DataBinder.Eval(Container.DataItem,"id")) %>'>
</asp:Image>
</ItemTemplate>
</asp:TemplateColumn>即绑定的是一个图片,在这种情况下,要如何生成分页呢????????
孟子E章作品出处:
http://dotnet.aspx.cc/ShowDetail.aspx?id=ECD9AE16-8FF0-4A1C-9B9F-5E8B641CB1B1