Hello all,
Hopefully I can explain this well. I have a formview with a datetimecontrol. I am trying to bind data I am retrieving from a database to it. I keep getting the error "Parser Error Message: The server tag is not well formed". I am not sure how to fix this. Below
is snippets of my code. The first textbox is binding fine.
This is part of my SqlDataSource Control:
<SelectParameters> <asp:Parameter Name= "ACTION" DefaultValue="sel" Type="String"> <asp:Parameter Name="REQUEST_ID" Type="Int32"> </SelectParameters> <Updateparameters> <asp:Parameter Name="ACTION" DefaultValue="upd" Type="String"> <asp:Parameter Name="REVISION" Type="String"> <asp:Parameter Name="REVISION_DATE" Type="String"> </UpdateParameters> This code is inside my formview control:<asp:TextBox ID="revisionTextBox" runat="server" Text='<%# Bind("REVISION") %>' Width="250px">
Generally, I only receive that error when I haven't properly closed the tags in my aspx page. (due to aspx pages being XHTML now instead of classic HTML)
If you post your aspx <body> code, I can check to see if thats what is throwing the error.
I actually found what the error was. I had a pair of double quotes inside each another set, but the Datetimecontrol is still not being bound to the database info. I could still use help with that.
I personally use just add an AJAX Calendar Extender to an already bound TextBox by clicking the smart tag of the textbox, click "Add Extender", select "Calendar Extender" and voila ..I have a bound TextBox with a popout calendar.
Here is my code: hopfully it is all there. I have problems posting code on this forum. For a little background the SelectParamater REQUEST_ID is set on the code behind page.
After looking into the Sharepoint DateTimeControl I came across this answer (link).
Basically you'd need to get the DateTimeControl's value and then just apply the string, both in the codebehind. "
string DateTo = ((TextBox)((Microsoft.SharePoint.WebControls.SPCompositeControl)(dtVacationTo)).Controls[0]).Text;
newitem["VacationStartDate"] = DateTime.Parse(DateFrom, new System.Globalization.CultureInfo("ar-EG")) ;
"
I must say that I still think that it would be much simpler to just add an AJAX Calendar Extender to a bound TextBox by clicking the smart tag of the textbox, click "Add Extender", select "Calendar Extender". If you need help with that just let me know. But
sorry girl, I just don't use Sharepoint controls. Maybe someone else in these forums will be able to help you better.
jmoshier
Member
2 Points
39 Posts
Binding to a DateTimeControl in a FormView
Dec 05, 2008 03:17 PM|LINK
Hello all,
Hopefully I can explain this well. I have a formview with a datetimecontrol. I am trying to bind data I am retrieving from a database to it. I keep getting the error "Parser Error Message: The server tag is not well formed". I am not sure how to fix this. Below is snippets of my code. The first textbox is binding fine.
This is part of my SqlDataSource Control: <SelectParameters> <asp:Parameter Name= "ACTION" DefaultValue="sel" Type="String"> <asp:Parameter Name="REQUEST_ID" Type="Int32"> </SelectParameters> <Updateparameters> <asp:Parameter Name="ACTION" DefaultValue="upd" Type="String"> <asp:Parameter Name="REVISION" Type="String"> <asp:Parameter Name="REVISION_DATE" Type="String"> </UpdateParameters> This code is inside my formview control:<asp:TextBox ID="revisionTextBox" runat="server" Text='<%# Bind("REVISION") %>' Width="250px"><SharePoint:DateTimeControl ID="revisionDate" runat="server" DateOnly="true" SelectedDate="<%# Bind("REVISION_DATE") %>" >
Any suggestions or help is greatly appreciated. If you need more code to understand please let me know.
Thanks,
Jenn
Mr.Bill
Participant
1046 Points
375 Posts
Re: Binding to a DateTimeControl in a FormView
Dec 05, 2008 03:53 PM|LINK
It would be difficult for any of us to give you any direction or even suggestions without knowing a little bit more about your situation.
What IDE or Designer are you using?
jmoshier
Member
2 Points
39 Posts
Re: Binding to a DateTimeControl in a FormView
Dec 05, 2008 03:58 PM|LINK
I am using Visual Studio 2008
Mr.Bill
Participant
1046 Points
375 Posts
Re: Binding to a DateTimeControl in a FormView
Dec 05, 2008 04:29 PM|LINK
OK..
Generally, I only receive that error when I haven't properly closed the tags in my aspx page. (due to aspx pages being XHTML now instead of classic HTML)
If you post your aspx <body> code, I can check to see if thats what is throwing the error.
jmoshier
Member
2 Points
39 Posts
Re: Binding to a DateTimeControl in a FormView
Dec 05, 2008 05:34 PM|LINK
I actually found what the error was. I had a pair of double quotes inside each another set, but the Datetimecontrol is still not being bound to the database info. I could still use help with that.
Mr.Bill
Participant
1046 Points
375 Posts
Re: Binding to a DateTimeControl in a FormView
Dec 05, 2008 05:41 PM|LINK
Sure.. but we need to see your actual code.
I personally use just add an AJAX Calendar Extender to an already bound TextBox by clicking the smart tag of the textbox, click "Add Extender", select "Calendar Extender" and voila ..I have a bound TextBox with a popout calendar.
jmoshier
Member
2 Points
39 Posts
Re: Binding to a DateTimeControl in a FormView
Dec 05, 2008 05:58 PM|LINK
Here is my code: hopfully it is all there. I have problems posting code on this forum. For a little background the SelectParamater REQUEST_ID is set on the code behind page.
<asp:SqlDataSource ID="requestSource" runat="server"
SelectCommand="sp_REQUEST"
SelectCommandType="StoredProcedure"
UpdateCommand="sp_REQUEST"
UpdateCommandType="StoredProcedure"
OnUpdated="FormView1_ItemUpdated">
<SelectParameters>
<asp:Parameter Name="ACTION" DefaultValue="sel" Type="String" />
<asp:Parameter Name="REQUEST_ID" Type="Int32" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="ACTION" DefaultValue="upd" Type="String" />
<asp:Parameter Name="CREATED_BY" Type="String" />
<asp:Parameter Name="REQUEST_ID" Type="Int32" />
<asp:Parameter Name="FULL_NAME" Type="String" />
<asp:Parameter Name="WORK_PHONE" Type="String" />
<asp:Parameter Name="DIVISION" Type="String" />
<asp:Parameter Name="COST_CENTER" Type="String" />
<asp:Parameter Name="STANDARD_INDEX" Type="String" />
<asp:Parameter Name="DESCRIPTION" Type="String" />
<asp:Parameter Name="REVISION" Type="String" />
<asp:ControlParameter Name="REVISION_DATE" ControlID="FormView1$revisionDate$revisionDateDate" PropertyName="Text" Type="String" />
<asp:Parameter Name="LINK" Type="String" />
<asp:Parameter Name="PRIORITY_ID" Type="String" />
<asp:Parameter Name="COMMENT" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
<asp:FormView ID="FormView1" runat="server" DefaultMode="Insert"
DataSourceID="requestSource">
<EditItemTemplate>
<table width="685" cellpadding="2" cellspacing="0" class="ms-toolbar">
<tr>
<td width="99%" class="ms-toolbar" nowrap><img src="/_layouts/images/blank.gif" width=1 height=18 alt=""></td>
<td class="ms-seperator" nowrap>
<span class="required">*</span> indicates a required field
</td>
</tr>
</table>
<br />
<table cellpadding="0" cellspacing="0" width="685" class="ms-formtable">
<tr>
<td class="ms-formlabel" colspan="2">Please Note.</td>
</tr>
<tr>
<td class="ms-formlabel" colspan="2">Personal Information:</td>
</tr>
<tr>
<td class="ms-formlabel">First Name:<span class="required">*</span></td>
<td class="ms-formbody">
<asp:TextBox ID="fullNameTextBox" runat="server" Text='<%# Bind("FULL_NAME") %>' Width="250px" /><br />
<asp:RequiredFieldValidator ID="fullNameValidator" Display="Dynamic" runat="server" ErrorMessage="Name is a required field" ControlToValidate="fullNameTextBox"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="ms-formlabel">Work Phone:<span class="required">*</span></td>
<td class="ms-formbody">
<asp:TextBox ID="workPhoneTextBox" runat="server" Text='<%# Bind("WORK_PHONE")%>' Width="250px" /><br />
<asp:RequiredFieldValidator ID="workPhoneValidator" Display="Dynamic" runat="server" ErrorMessage="Work Phone is a required field" ControlToValidate="workPhoneTextBox"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="ms-formlabel" valign="top">Division:<span class="required">*</span></td>
<td class="ms-formbody">
<asp:TextBox ID="divisionTextBox" runat="server" Text='<%# Bind("DIVISION") %>' Width="250px" />
</td>
</tr>
<tr>
<td class="ms-formlabel">Cost Center:<span class="required">*</span></td>
<td class="ms-formbody">
<asp:TextBox ID="costCenterTextBox" runat="server" Text='<%# BIND("COST_CENTER") %>' Width="250px" /><br />
<asp:RequiredFieldValidator ID="costCenterValidator" Display="Dynamic" runat="server" ErrorMessage="Cost Center is a required field" ControlToValidate="costCenterTextBox"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="ms-formlabel" colspan="2">Standard Information:</td>
</tr>
<tr>
<td class="ms-formlabel" valign="top">Standard Index:<span class="required">*</span><br />(i.e. GR-929-CORE)</td>
<td class="ms-formbody">
<asp:TextBox ID="standardIndexTextBox" runat="server" Text='<%# Bind("STANDARD_INDEX") %>' Width="250px" /><br />
<asp:RequiredFieldValidator ID="standardIndexValidator" Display="Dynamic" runat="server" ErrorMessage="Standard Index is a required field" ControlToValidate="standardIndexTextBox"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="ms-formlabel" valign="top">Title/Description:<span class="required">*</span></td>
<td class="ms-formbody">
<asp:TextBox ID="descriptionTextBox" runat="server" Text='<%# Bind("DESCRIPTION") %>' Columns="40" Rows="5" TextMode="MultiLine" CssClass="formField" /><br />
<asp:RequiredFieldValidator ID="descriptionValidator" Display="Dynamic" runat="server" ErrorMessage="Title/Descritpion is a required field" ControlToValidate="descriptionTextBox"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="ms-formlabel" valign="top">Revision:</td>
<td class="ms-formbody">
<asp:TextBox ID="revisionTextBox" runat="server" Text='<%# Bind("REVISION") %>' Width="250px" />
</td>
</tr>
<tr>
<td class="ms-formlabel" valign="top">Revision Date:</td>
<td class="ms-formbody">
<SharePoint:DateTimeControl ID="revisionDate" runat="server" DateOnly="true" SelectedDate="" />
</td>
</tr>
<tr>
<td class="ms-formlabel" valign="top">External Web Link:</td>
<td class="ms-formbody">
http:// <asp:TextBox ID="linkTextBox" runat="server" Text='<%# Bind("LINK") %>' Width="250px" />
</td>
</tr>
<tr>
<td class="ms-formlabel" valign="top">Priority:<span class="required">*</span></td>
<td class="ms-formbody">
<asp:DropDownList ID="priorityList" runat="server"
DataSourceID="priorityBox" DataTextField="PRIORITY"
DataValueField="PRIORITY_ID" AppendDataBoundItems="true" SelectedValue='<%# Bind("PRIORITY_ID") %>'>
<asp:ListItem Value="">-----------Select a Priority-----------</asp:ListItem>
</asp:DropDownList><br />
<asp:RequiredFieldValidator ID="priorityValidator" Display="Dynamic" runat="server" ErrorMessage="Priority is a required field" ControlToValidate="priorityList"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="ms-formlabel" valign="top">Reason/Purpose of Request:<span class="required">*</span></td>
<td class="ms-formbody">
<asp:TextBox ID="reasonTextBox" runat="server" Text='<%# Bind("COMMENT") %>' Columns="40" Rows="5" TextMode="MultiLine" CssClass="formField" /><br />
<asp:RequiredFieldValidator Display="Dynamic" ID="reasonValidator" runat="server" ErrorMessage="Reson/Purpose of Request" ControlToValidate="reasonTextBox"></asp:RequiredFieldValidator>
</td>
</tr>
<tr><td class="ms-formline" colspan="2"> </td></tr>
</table>
<table cellpadding="0" cellspacing="0" width="685">
<tr>
<td align="right" class="ms-vb">
<asp:TextBox ID="userNameTextBox" runat="server" Text='<%# Bind("CREATED_BY") %>' Visible="false" />
<asp:TextBox ID="requestIDTextBox" runat="server" Text='<%# Bind("REQUEST_ID") %>' Visible="false" />
<asp:Button ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Submit" CssClass="formButton" />
</td>
</tr>
</table>
</EditItemTemplate>
</asp:FormView>
Mr.Bill
Participant
1046 Points
375 Posts
Re: Binding to a DateTimeControl in a FormView
Dec 05, 2008 07:06 PM|LINK
After looking into the Sharepoint DateTimeControl I came across this answer (link).
Basically you'd need to get the DateTimeControl's value and then just apply the string, both in the codebehind. "
string DateTo = ((TextBox)((Microsoft.SharePoint.WebControls.SPCompositeControl)(dtVacationTo)).Controls[0]).Text; newitem["VacationStartDate"] = DateTime.Parse(DateFrom, new System.Globalization.CultureInfo("ar-EG")) ;"I must say that I still think that it would be much simpler to just add an AJAX Calendar Extender to a bound TextBox by clicking the smart tag of the textbox, click "Add Extender", select "Calendar Extender". If you need help with that just let me know. But sorry girl, I just don't use Sharepoint controls. Maybe someone else in these forums will be able to help you better.
Mr.Bill
Participant
1046 Points
375 Posts
Re: Binding to a DateTimeControl in a FormView
Dec 15, 2008 04:53 PM|LINK
Did you ever find resolution to this issue?
jmoshier
Member
2 Points
39 Posts
Re: Binding to a DateTimeControl in a FormView
Dec 15, 2008 05:04 PM|LINK
Yes I did...here a snippet of the code I used
<
asp:ControlParameter Name="REVISION_DATE" ControlID="FormView1$revisionDate$revisionDateDate" PropertyName="Text" Type="String" /><
SharePoint:DateTimeControl ID="revisionDate" runat="server" DateOnly="true" SelectedDate='<%# (DataBinder.Eval(Container.DataItem, "REVISION_DATE") is DBNull ? Convert.ToDateTime(null):DataBinder.Eval(Container.DataItem, "REVISION_DATE")) %>' />