A strange issue!

M

Martyn Fewtrell

I have a repeater that displays records from a database.

All fairly straight forward with the repeater binding to a dataset, and a
datacommand filling the dataset from the database. The only complication is
that the data displayed can come from either of two stored procedures
according to a checkbox selection. If you check the checkbox the page uses
one data command to get data from the database and if you don't check the
checkbox then the page uses a different datacommand to provide a different
set of data but to the same dataset. Both sets of data fit the same template
and therefore is correctly laid out by the repeater (in fact the data comes
from the same database table).

The complication is that one of the fields in the repeater is a textbox with
the Text value bound to the date value from the dataset. As a result the
repeater provides the date value in the text box (which can later be used
for editing).

<asp:repeater id="repJobs" runat="server" enableviewstate="False"
onitemcommand="Job_Detail" DataMember="LiveJobs" DataSource="<%# dsManJobs
%>">
<itemtemplate>
<tr>
<td><asp:linkbutton id="link" runat="server" commandname="JobID"
commandargument='<%# DataBinder.Eval(Container, "DataItem.JobID") %>' >
<asp:Literal ID="litID" Text='<%# DataBinder.Eval(Container,
"DataItem.JobID") %>' Runat="server" ></asp:Literal></asp:linkbutton></td>
<td><%# DataBinder.Eval(Container, "DataItem.Title") %></td>
<td class="right"><%# DataBinder.Eval(Container, "DataItem.Name") %></td>
<td class="center"><asp:TextBox id="txtMassDate" runat="server" Width="75px"
Text='<%# DataBinder.Eval(Container, "DataItem.AddStop", "{0:d/MM/yyyy}")
%>'></asp:TextBox></td>
<td class="center"><asp:CheckBox id="chkDelete"
runat="server"></asp:CheckBox></td></tr>
</itemtemplate>
<headertemplate></headertemplate>
<footertemplate></table></footertemplate>
</asp:repeater>

The problem is that although when you load the first set of data, everything
works correctly with the correct dates displayed, when you then check the
checkbox and repost the page to view the alternative data the dates in the
textbox's displayed are those from the earlier page? I know the data in the
dataset is correct as when i bind a datagrid to the same dataset the data in
the grid is displayed with the correct dates for either set of data etc. I
have tried turning off the viewstate on the checkbox but this doesn't appear
to make any difference!

Any suggestions?

Martyn Fewtrell
(e-mail address removed)
 
G

Guest

This is a silly question but do have a Page.IsPostBack check around your Databind() method in page_load? Because if you do have that and then don't rebind your repeater on postback, like in the checkbox.OnClick event, it won't be getting rebound

-J
 
M

Martyn Fewtrell

Thanks for your input - know question is to silly!

There is a page is post back clause that chooses the appropriate routine to
run to load the correct data into the dataset according to the checkbox
selection. The repeater is then bound to the dataset. I assume anyway that
if this was not the case then the other elements in the repeater like the
link button and the name wouldn't load correctly and these do all display
the correct data and function correctly.

I assume that the issue is something to do with the binding on the textbox
(something that I haven't done before in this context).

Martyn Fewtrell
(e-mail address removed)


John Linn said:
This is a silly question but do have a Page.IsPostBack check around your
Databind() method in page_load? Because if you do have that and then don't
rebind your repeater on postback, like in the checkbox.OnClick event, it
won't be getting rebound.
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top