ASP datagrid style question while using paging

R

Randy

Hello,
I've got an ASP app. I have a simple datagrid. If I don't use column
templates I can easily set up the datagrid to use paging by creating a
PageIndexChanged event and putting this code in it...
DataGrid1.CurrentPageIndex = e.NewPageIndex;
DataGrid1.DataBind();
This works fine. But when I then use column styles for the datagrid using
Labels in the item template slot, when I click the next page link at the
bottom of the datagrid, when the code hits the DataGrid1.DataBind();
it bombs with the error...
The IListSource does not contain any data sources.

Does anyone know how to fix this?

Thanks for any help
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi Randy,

Could you post some code, I use a grid binded to a strong typed collection
and I have no problem with the paging,
A tip, do not use label in the templatecolumn, use a <span> instead as this:

<asp:templatecolumn ItemStyle-VerticalAlign="Top" ItemStyle-Width="65"
ItemStyle-HorizontalAlign="left" >
<itemtemplate>
<span ><%# ((CtpRecord)Container.DataItem).Status %></span>
</itemtemplate>
</asp:templatecolumn>

This avoid the creation of a Label control


cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top