When I run
this code, I'm having this problem, because when I select a different date from the calendar control (Articles.aspx), even though the data should be refreshed within the formview it does not refresh. It is connected to an SQL Data Source, and, from Visual Studio it seems that the SQL Statement is being updated, however, I must be missing something out.
Articles.aspx
<div>
<asp:calendar id="calArticles" runat="server" backcolor="White" xmlns:asp="#unknown">
BorderColor="#999999" CellPadding="4" DayNameFormat="Shortest"
Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" Height="180px"
Width="200px" onselectionchanged="calArticles_SelectionChanged">
<selecteddaystyle backcolor="#666666" font-bold="True" forecolor="White" />
<selectorstyle backcolor="#CCCCCC" />
<weekenddaystyle backcolor="#4AA02C" />
<todaydaystyle backcolor="#CCCCCC" forecolor="Black" />
<othermonthdaystyle forecolor="#808080" />
<nextprevstyle verticalalign="Bottom" />
<dayheaderstyle backcolor="#CCCCCC" font-bold="True" font-size="7pt" />
<titlestyle backcolor="#999999" bordercolor="Black" font-bold="True" />
</asp:calendar>
<asp:formview id="Envelope" runat="server" datasourceid="SqlDataSource1" xmlns:asp="#unknown">
AllowPaging="True">
<headertemplate>
</headertemplate>
<edititemtemplate>
<p> <asp:textbox runat="server" width="1000" readonly="false" id="txtSubject" text="<%# Eval("Subject")%>"></asp:textbox> </p>
<p> <asp:textbox runat="server" height="300" width="1000" readonly="false" id="txtBody" textmode="MultiLine" text="<%# Eval("EntryText") %>"></asp:textbox>
<p>
<asp:button id="btnNew" runat="server" text="New" commandname="New" />
<asp:button id="btnEdit" runat="server" text="Edit" commandname="Edit" />
<asp:button id="btnSave" runat="server" text="Save" commandname="Update" />
<asp:button id="btnCancel" runat="server" text="Cancel" commandname="Cancel" />
<asp:button id="btnRefresh" runat="server" text="Refresh" />
<asp:button id="btnDelete" runat="server" text="Delete" enabled="False" />
</p>
</p>
</edititemtemplate>
</asp:formview>
<p>
<asp:textbox id="TextBox2" runat="server" width="211px" xmlns:asp="#unknown"></asp:textbox>
<asp:button id="btnSearch" runat="server" text="Search" xmlns:asp="#unknown" />
</p>
<p>
<asp:label id="lblFooter" runat="server" xmlns:asp="#unknown"></asp:label>
</p>
<asp:sqldatasource id="SqlDataSource1" runat="server" xmlns:asp="#unknown">
ConnectionString="<%$ ConnectionStrings:couch_dbConnectionString %>"
SelectCommand="SELECT [Timestamp], [Subject], [EntryText] FROM [Article]"></asp:sqldatasource>
</div>
Articles.aspx.cs
public partial class Articles : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.Title = "Jon's Couch";
Envelope.DataBind();
}
protected void calArticles_SelectionChanged(object sender, EventArgs e)
{
SqlDataSource1.SelectCommand =
System.String.Concat("SELECT [Timestamp], [Subject], [EntryText] FROM [Article] WHERE [Timestamp] >= '" +
calArticles.SelectedDate.ToString() + "' AND [Timestamp] < (DATEADD(day, 1, [Timestamp]));");
Envelope.DataBind();
}
When I select 'Edit' or 'Add' the textboxes simply disappear, whilst when I select Save, this error is displayed:
FormView 'Envelope' must be in edit mode to update a record.
:confused:
Screendumps
here illustrate the issues.
:confused: