Suggestions? Never used one before.
On Nov 12, 10:48 am, Jamie Fraser <[email protected]> wrote: > Please don't post code to the list. Use a code sharing site to make it > readable.On Fri, Nov 12, 2010 at 4:39 PM, Stacie <[email protected]> wrote: > > I have added code to my formview edititemtemplate so that whenever a > > user clicks any of the pager links (Prev, Next, etc) it automatically > > updates the record. If the page is valid it updates the changes as > > expected. However, if there are validation errors it doesn't update > > but it also doesn't show the users the validation messages from my > > validation controls. I realize that there is some line of code I am > > missing but I'm not sure how to get it to show the validation > > messages. How do I get the validation messages to show when there are > > validation errors? > > > VB code: > > > Protected Sub fvProjects2_PageIndexChanging(ByVal sender As > > System.Object, ByVal e As > > System.Web.UI.WebControls.FormViewPageEventArgs) Handles > > fvProjects2.PageIndexChanging > > > Page.Validate() > > > If Page.IsValid Then > > fvProjects2.UpdateItem(True) > > > End If > > > End Sub > > > Formview Edit Template code: > > <EditItemTemplate> > > > <table cellpadding="0" width="900" cellspacing="0" > > border="0"> > > <tr valign="top"> > > <td width="20%"></td> > > <td width="60%" align="center"><PagerSettings > > FirstPageText="First" LastPageText="Last" Mode="NextPreviousFirstLast" > > NextPageText="Next" PageButtonCount="100" > > PreviousPageText="Previous" /></td> > > <td width="20%" align="right"> > > > </td> > > </tr> > > </table> > > > <table class="projects" width="900" cellpadding="0" > > cellspacing="0"> > > <tr> > > <td class="header" style="width: 250px"> > > Priority:</td> > > <td class="details" style="width: 292px"> > > <asp:DropDownList ID="ddl_priority" > > runat="server" SelectedValue='<%# Bind("Priority") %>'> > > <asp:ListItem>1</asp:ListItem> > > <asp:ListItem>2</asp:ListItem> > > <asp:ListItem>3</asp:ListItem> > > <asp:ListItem>4</asp:ListItem> > > <asp:ListItem>5</asp:ListItem> > > </asp:DropDownList></td> > > <td class="header" style="width:250px"> > > Win Probability:</td> > > <td class="details"> > > <asp:DropDownList ID="ddl_winprob" > > runat="server" SelectedValue='<%# Bind("Win_Probability") %>'> > > <asp:ListItem Value="20" > > Selected="True">20%</asp:ListItem> > > <asp:ListItem Value="40">40%</ > > asp:ListItem> > > <asp:ListItem Value="60">60%</ > > asp:ListItem> > > <asp:ListItem Value="80">80%</ > > asp:ListItem> > > </asp:DropDownList> > > <asp:Label ID="Label11" runat="server" > > CssClass="requiredfield" Text="*"></asp:Label></td> > > </tr> > > <tr> > > <td class="header" style="width: 168px"> > > Project Name:</td> > > <td class="details" style="width: 292px"> > > <asp:TextBox ID="ProjectNameTextBox" > > runat="server" Text='<%# Bind("ProjectName") %>' > > Width="246px" Height="33px" > > TextMode="MultiLine"></asp:TextBox> > > <asp:Label ID="Label19" runat="server" > > CssClass="requiredfield" Text="*"></asp:Label> > > <asp:RequiredFieldValidator > > ID="RequiredFieldValidator3" runat="server" > > ControlToValidate="ProjectNameTextBox" > > CssClass="errormessages" Display="Dynamic" > > ErrorMessage="Project Name is a required field. " > > SetFocusOnError="True"></ > > asp:RequiredFieldValidator></td> > > <td class="header" style="width: 147px"> > > Est. Value:</td> > > <td class="details"> > > <asp:TextBox ID="Est_ValueTextBox" > > runat="server" Text='<%# Bind("Est_Value") %>' > > Width="64px"></asp:TextBox> > > <asp:Label ID="Label18" runat="server" > > CssClass="requiredfield" Text="*"></asp:Label> > > <strong>Million<asp:CompareValidator > > ID="cvEstValue" runat="server" > > ControlToValidate="Est_ValueTextBox" CssClass="errormessages" > > Display="Dynamic" ErrorMessage="Estimated > > Value must be greater than 0. " Operator="GreaterThanEqual" > > SetFocusOnError="True" Type="Double" > > ValueToCompare="0.0" > > Width="100%"></asp:CompareValidator></ > > strong></td> > > </tr> > > <tr> > > <td class="header"> > > Bid Documents:</td> > > <td class="details"> > > <cc2:DatePicker ID="date_bidrelease" > > runat="server" CalendarPosition="DisplayRight" > > DateValue='<%# Bind("Bid_ReleaseDate") > > %>' /> > > <asp:Label ID="Label20" runat="server" > > CssClass="requiredfield" Text="*"></asp:Label> > > <asp:CompareValidator ID="cvbidrelease" > > runat="server" ControlToValidate="date_bidrelease" > > CssClass="errormessages" Display="Dynamic" > > ErrorMessage="Bid Release Date must be a valid date (mm/dd/yyyy)" > > Operator="DataTypeCheck" Type="Date" > > SetFocusOnError="True"></asp:CompareValidator></td> > > <td class="header" style="width: 147px; height: > > 48px"> > > Owner:</td> > > <td class="details" style="height: 48px"> > > <asp:DropDownList ID="ddl_owner" > > runat="server" DataSourceID="SqlDataOwners" DataTextField="Owner" > > DataValueField="OwnerID" SelectedValue='< > > %# Bind("OwnerID") %>' Width="216px"> > > </asp:DropDownList></td> > > </tr> > > <tr> > > <td class="header"> > > Est. Const. Start :</td> > > <td class="details"> > > <cc2:DatePicker ID="date_startdate" > > runat="server" CalendarPosition="DisplayRight" > > DateValue='<%# Bind("Est_StartDate") %>' / > > > <asp:Label ID="Label22" runat="server" > > CssClass="requiredfield" Text="*"></asp:Label> > > <asp:CompareValidator ID="cvconstartdate" > > runat="server" ControlToValidate="date_startdate" > > CssClass="errormessages" Display="Dynamic" > > ErrorMessage="Est. Bid Date must be a valid date format (mm/dd/yyyy)." > > Operator="DataTypeCheck" Type="Date" > > SetFocusOnError="True"></asp:CompareValidator></td> > > <td class="header" style="width: 147px; height: > > 48px"> > > CM/GC:</td> > > <td class="details" style="height: 48px"> > > <asp:TextBox ID="CM_GCTextBox" runat="server" > > Text='<%# Bind("CM_GC") %>' Width="286px"></asp:TextBox></td> > > </tr> > > <tr> > > <td class="header"> > > Construction > > <br /> > > Duration:</td> > > <td class="details"> > > <asp:TextBox ID="tboxconduration" > > runat="server" Width="58px" Text='<%# Bind("Est_Duration", "{0:N1}") > > %>'></asp:TextBox> > > <asp:Label ID="Label23" runat="server" > > CssClass="requiredfield" Text="*"></asp:Label> > > <strong>Months<asp:RequiredFieldValidator > > ID="rvduration" runat="server" ControlToValidate="tboxconduration" > > CssClass="errormessages" > > Display="Dynamic" ErrorMessage="Construction Duration is required." > > SetFocusOnError="True"></ > > asp:RequiredFieldValidator><asp:CompareValidator ID="cvconduration" > > runat="server" ControlToValidate="tboxconduration" > > CssClass="errormessages" > > Display="Dynamic" ErrorMessage="Construction Duration must be greater > > than 0." > > Operator="GreaterThan" Type="Double" > > ValueToCompare="0.0" SetFocusOnError="True"></asp:CompareValidator></ > > strong></td> > > <td class="header" style="width: 147px; height: > > 48px"> > > Architect/<br /> > > Engineer:</td> > > <td class="details" style="height: 48px"> > > <asp:TextBox ID="Architect_EngineerTextBox" > > runat="server" Text='<%# Bind("Architect_Engineer") %>' > > Width="270px"></asp:TextBox></td> > > </tr> > > <tr> > > <td class="header" style="width: 168px; height: > > 20px"> > > Scope:</td> > > <td class="details" style="width: 292px; height: > > 20px"> > > <asp:TextBox ID="ScopeTextBox" runat="server" > > Height="31px" Text='<%# Bind("Scope") %>' > > Width="238px"></asp:TextBox></td> > > <td class="header" style="width: 147px; height: > > 20px"> > > Market:</td> > > <td class="details" style="height: 20px"> > > <asp:DropDownList ID="ddl_market" > > runat="server" DataSourceID="SqlDataMarkets" DataTextField="Market" > > DataValueField="MarketID" SelectedValue='< > > %# Bind("MarketID") %>' Width="224px"> > > </asp:DropDownList></td> > > </tr> > > <tr> > > <td class="header" style="width: 168px; height: > > 20px"> > > Project Description:</td> > > <td class="details" style="width: 292px; height: > > 20px"> > > <asp:TextBox ID="ProjectDescriptionTextBox" > > runat="server" Height="60px" Text='<%# Bind("ProjectDescription") %>' > > Width="300px" MaxLength="100" > > TextMode="MultiLine"></asp:TextBox> > > <cc1:TextBoxCounter > > ID="tboxcounterdescription" runat="server" Font-Bold="True" > > ForeColor="#000000" > > MaxCharacterLength="1000" > > TextBoxControlId="ProjectDescriptionTextBox" Width="300px" > > DataFormatString="Character Max. {5}; {3} remaining" /> > > </td> > > <td class="header" style="width: 147px; height: > > 20px"> > > Comments/Next Steps:</td> > > <td class="details" style="height: 20px"> > > <asp:TextBox ID="CommentsTextBox" > > runat="server" Height="60px" Text='<%# Bind("Comments") %>' > > Width="289px" MaxLength="500" > > TextMode="MultiLine"></asp:TextBox> > > <cc1:TextBoxCounter ID="tboxcountercomments" > > runat="server" Font-Bold="True" ForeColor="#000000" > > MaxCharacterLength="500" > > TextBoxControlId="commentstextbox" Width="300px" > > DataFormatString="Character Max. {5}; {3} remaining" /> > > </td> > > </tr> > > <tr> > > <td class="header" style="width: 168px; height: > > 20px"> > > Construction Type:</td> > > <td class="details" style="width: 292px; height: > > 20px"> > > <asp:ListBox ID="lbox_ConstructionType" > > runat="server" Width="195px" DataSourceID="SqlDataConstructionTypes" > > DataTextField="Construction_Type" DataValueField="Construction_Type" > > Height="84px"></asp:ListBox><br /> > > <strong>Hold Ctrl or Shift button to select > > multiple values.</strong></td> > > <td class="header" style="width: 147px; height: > > 20px"> > > Location:</td> > > <td class="details" style="height: 20px"> > > <asp:TextBox ID="LocationTextBox" > > runat="server" Text='<%# Bind("Location") %>' Width="261px"></ > > asp:TextBox></td> > > </tr> > > <tr> > > <td class="header" style="width: 168px; height: > > 20px"> > > Branch Office:</td> > > <td class="details" style="width: 292px; height: > > 20px"> > > <asp:DropDownList ID="ddl_branch" > > runat="server" DataSourceID="SqlDataOffice" > > DataTextField="Branch_Office" > > DataValueField="Branch_OfficeID" SelectedValue='<%# > > Bind("BranchOfficeID") %>' > > Width="224px"> > > </asp:DropDownList></td> > > <td class="header" style="width: 147px; height: > > 20px"> > > Sponsor:</td> > > <td class="details" style="height: 20px"> > > <asp:DropDownList ID="ddl_sponsor" > > runat="server" DataSourceID="SqlDataSponsors" > > DataTextField="Sponsor" > > DataValueField="SponsorInitials" SelectedValue='<%# Bind("SponsorID") > > %>' > > Width="229px"> > > </asp:DropDownList></td> > > </tr> > > <tr> > > <td class="header" style="width: 168px; height: > > 20px"> > > Status:</td> > > <td class="details" colspan="3" style="height: > > 20px"> > > <asp:DropDownList ID="ddl_status" > > runat="server" DataSourceID="SqlDataStatuses" > > DataTextField="Status" > > DataValueField="ProjectStatusID" SelectedValue='<%# Bind("StatusID") > > %>' > > Width="230px"> > > </asp:DropDownList> > > <asp:TextBox ID="ModifiedDateTextBox" > > runat="server" Text='<%# Bind("ModifiedDate") %>' > > Visible="False" Width="56px"></asp:TextBox><asp:TextBox > > ID="ModifiedByTextBox" runat="server" > > ReadOnly="True" Text='<%# Bind("ModifiedBy") %>' > > Visible="False"></asp:TextBox></td> > > </tr> > > </table> > > <div style="width:115px; float:right;"> > > <div class="linkbutton-l"><asp:LinkButton > > ID="UpdateButton" runat="server" CausesValidation="True" > > CommandName="Update" > > Text="Update"></asp:LinkButton></div> > > <div class="linkbutton-r"> > > <asp:LinkButton ID="UpdateCancelButton" runat="server" > > CausesValidation="False" CommandName="Cancel" > > Text="Cancel"></asp:LinkButton></div> > > <div class="clear"></div> > > </div> > > > </EditItemTemplate>
