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)
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)