Repeater Control


i am having problem with ViewState.
i am using Repeater Control,its take long time to bind data,i am bind only 400 records to repeater,if i see Viewstate its generates 20 pages of viewsate.


.aspx page

<asp:Repeater runat=“server” ID=“Repeater1” OnItemCommand=“Patients_ItemCommand” OnItemDataBound=“Patients_ItemDataBound” > <ItemTemplate><table width=“92%” border=“0” cellspacing=“1” cellpadding=“1”><tr><td align=“left”> <asp:LinkButton ID=“Patname” runat=“server” CommandArgument=‘<%#Eval(“id”) %>’ CommandName=“EditPat” Font-Bold=“false” Text=‘<%#Eval(“Patient”) %>’ ToolTip=‘<%#Eval(“PatientNumber”) %>’></asp:LinkButton></td>
<td width=“30%” align=“right”><asp:Label ID=“lblcreateddate” runat=“server” Text=‘<%#Eval(“CreatedDate”) %>’></asp:Label></td><td width=“2%” align=“right”><a href=‘report.aspx?id= + <%#Eval(“id”) %>’ title=“Print Patient Details”><img alt=“” border=“0” src=“images/print2.jpg” /></a></td>
<td width=“2%” align=“right”> <asp:CheckBox ID=“chkdelete” runat=“server” TextAlign=“Left” /> </td></tr>


     Repeater1.DataSource = dvdis.ToTable();

can any one please help out.

have you tried <asp:Repeater … EnableViewState=“False” >

you already seeing the problem. more data = more time to load
get used to using enableviewstate=false :slight_smile:

The only time I ever use viewstate, is only if it is needed. For forms or other pages with post backs that need to persist their data. I usually disable viewstate site wide in the web.config and then only enable it on pages that need it.

And on another note, why would you be loading 400 records into a repeater? I would strongly suggest paging on a control like this. Paging is easy with linq2sql, but can be done with normal ADO.NET if your not using linq2sql

Switch to MVC and you can avoid all of this.