-
tavogardo
-
-
-
Joined on 05-02-2008
-
-
Posts 3
-
-
|
Failed to load Viewstate Error occurs when using Cute Editor
I am trying out CuteEditor to see if I can use it on my websites. I first fill a gridview with data from a Sql Table. I then select a detailsview of the item I am interested in. But, when I when I click on the Edit button, it returns to the gridview instead of entering the edit mode of the detailsview. If I then click the select button on the gridview , I get the following error:
Server Error in '/solutions' Application.
Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
Stack Trace:
[HttpException (0x80004005): Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.]
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +310
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +136
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +224
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +136
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +224
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +136
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +224
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +136
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +224
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +136
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +224
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +136
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +224
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +136
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +224
System.Web.UI.Page.LoadAllState() +439
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1092
|
Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433
My ASPX page code is listed below:
<% @ Page Language="VB" AutoEventWireup="false" ValidateRequest="false" CodeFile="TextClipsMaintenance.aspx.vb"
Inherits="SysMaint_TextClipsMaintenance" %>
<% @ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
<% @ Import Namespace="Common.Utility.Utils" %>
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns="http://www.w3.org/1999/xhtml" lang="en-us">
< head id="Head1" runat="server">
<title>Abilities!: Text Clips Maintenance</title>
<link rel ="stylesheet" type="text/css" href ="c/abilities.css" />
<link rel ="stylesheet" type="text/css" href ="c/abil.css" />
<link rel ="stylesheet" type="text/css" href ="c/epoch_styles.css" />
<script type="text/javascript" src ="js/epoch_classes.js" />
<script type="text/javascript">
var startCal, endCal;
window.onload = function() {
startCal = new Epoch('cal1','popup',document.getElementById('dvClips_tbStartDate'));
endCal = new Epoch('cal1','popup',document.getElementById('dvClips_tbEndDate'));
};
</script>
<style type="text/css">
#maintSection caption
{
font-size: 14pt;
color: #000;
font-weight: bold;
}
.cmdbutton {
border: solid black 1px;
background-color: white;
color: black;
}
DIV.base {
display:block;
width:auto;
margin:0;
padding:0;
}
DIV.left {
display :inline;
width: 18%;
float : left;
margin : 0;
padding : 0;
}
DIV.right {
display :inline;
width:auto;
border : none;
float : left;
margin : 0;
padding : 0;
vertical-align:middle;
}
</ style>
</ head>
< body>
<a id="top" title="Top of Page"></a>
<div id="page">
<div class="skip">
<a href="#links">skip to links</a></div>
<div class="skip">
<a href="#content">skip to main content</a></div>
<div id="pageHeading" title="Page Heading containing our Logo">
<div class="banner" id="main">
<a href="http://www.abilitiesonline.org/" tabindex="0" title="Abilities! Home Page.">
Abilities! </a></div>
<div id="mainNav" title="Main Navigation Links, Top of Page">
<div id="mainNavLinks">
</div>
</div>
</div>
<div id="container">
<div id="fullPageContent" title="Page Main Content Area">
<form id="form1" runat="server">
<div id="maintSection">
<br />
<h1>
Text Clips Maintenance </h1>
<br />
<asp:Panel ID="pnlListing" runat="server">
<asp:GridView ID="gvClips"
runat="server"
AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False"
DataKeyNames="Id"
DataSourceID="SqlDataSource1"
CellPadding="5"
GridLines="Horizontal"
BorderColor="Black"
BorderWidth="1"
Caption="List of Current Text Clips"
CaptionAlign="Top">
<PagerSettings Mode="NumericFirstLast" />
<HeaderStyle HorizontalAlign="Center" BackColor="#E7E7E7" />
<AlternatingRowStyle BackColor="#E7E7E7" />
<RowStyle VerticalAlign="top" />
<Columns>
<asp:BoundField DataField="Id" Visible="false" />
<asp:TemplateField HeaderText="Entry Type" AccessibleHeaderText="Type of entry being displayed.">
<ItemTemplate>
<asp:Label OnDataBinding="convertType" ID="lblType" runat="server" Text='<%#Eval("EntryType")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Clip Descriptive Text"
AccessibleHeaderText="The text that will be displayed in the clip box.">
<ItemTemplate >
<asp:Label ID="lblClip" runat="server" Text='<%#Eval("ItemDescriptiveText") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ButtonType="Button"
ShowSelectButton="True"
ShowDeleteButton="true"
SelectText="Details"
AccessibleHeaderText="Action buttons">
<ControlStyle CssClass="cmdbutton" />
</asp:CommandField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NCDS %>"
SelectCommand="SELECT [Id], [EntryType], [StartDisplayDate], [EndDisplayDate], [ItemDescriptiveText] FROM [AbilitiesTextClips]"
DeleteCommand="DELETE FROM [AbilitiesTextClips] WHERE [Id] = @Id"></asp:SqlDataSource>
<div class="maintLink">
<asp:HyperLink ID="hlReturn" runat="server" NavigateUrl="../MyLinks.aspx"><Return To Maintenance Menu</asp:HyperLink>
</div>
</asp:Panel>
<asp:Panel ID="pnlDetails" runat="server">
<h3>
Selected Clip Details </h3>
<div class="reqMesg">
(R) Indicates a Required Field. </div>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
<br />
<asp:Label ID="lblMesg" runat="server" CssClass="req"></asp:Label>
<asp:DetailsView ID="dvClips"
runat="server"
AutoGenerateRows="False"
DataKeyNames="Id"
DataSourceID="SqlDataSource2"
CellPadding="5"
GridLines="both"
BorderColor="Black"
BorderWidth="1"
OnItemDeleted="detailDeleted"
OnItemInserting="itemInserting"
OnItemInserted="itemInserted"
OnItemUpdating="itemUpdating"
OnItemUpdated="itemUpdated"
Width="100%">
<FieldHeaderStyle BackColor="#E7E7E7" Width="20%" />
<RowStyle VerticalAlign="top" />
<Fields>
<asp:BoundField DataField="Id" HeaderText="Clip Id:" InsertVisible="False" ReadOnly="True"
SortExpression="Id" />
<asp:TemplateField HeaderText="Clip Entry Type:" AccessibleHeaderText="Type of entry being displayed.">
<ItemTemplate>
<asp:DropDownList ID="ddlET" runat="server" SelectedValue='<%#Eval("EntryType")%>'
Enabled="false" DataSourceID="XmlDataSource1"
DataTextField="text" DataValueField="value">
</asp:DropDownList>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/App_Data/ClipTypes.xml">
</asp:XmlDataSource>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlET" runat="server" SelectedValue='<%#Eval("EntryType")%>' DataSourceID="XmlDataSource1"
DataTextField="text" DataValueField="value">
</asp:DropDownList>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/App_Data/ClipTypes.xml">
</asp:XmlDataSource>
<span class="req">(R)</span>
<asp:RequiredFieldValidator ID="rfv1" ControlToValidate="ddlET" runat="server" ErrorMessage="An entry type must be selected."
CssClass="req">*</asp:RequiredFieldValidator>
</EditItemTemplate>
<InsertItemTemplate>
<asp:DropDownList ID="ddlET" runat="server" DataSourceID="XmlDataSource1"
DataTextField="text" DataValueField="value">
</asp:DropDownList>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/App_Data/ClipTypes.xml">
</asp:XmlDataSource>
<span class="req">(R)</span>
<asp:RequiredFieldValidator ID="rfv1" ControlToValidate="ddlET" runat="server" ErrorMessage="An entry type must be selected."
CssClass="req">*</asp:RequiredFieldValidator>
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Start Displaying On:" AccessibleHeaderText="Date to start displaying this clip.">
<ItemTemplate>
<% #Eval("StartDisplayDate", "{0:d}")%>
</ItemTemplate>
<EditItemTemplate>
<div class="base">
<div class="left">
<asp:TextBox ID="tbStartDate" Columns="10" MaxLength="10" Text='<%#Eval("StartDisplayDate", "{0:d}") %>'
runat="server"></asp:TextBox>
</div>
<div class="right">
<img style="height: 16px; width: 16px; border: 0" src="<%=GetSite() %>/img/cal.gif"
title="Select Date" alt="" onclick="startCal.toggle();" /></div>
</div>
</EditItemTemplate>
<InsertItemTemplate>
<div class="base">
<div class="left">
<asp:TextBox ID="tbStartDate" Columns="10" MaxLength="10" runat="server"></asp:TextBox>
</div>
<div class="right">
<img style="height: 16px; width: 16px; border: 0" src="<%=GetSite() %>/img/cal.gif"
title="Select Date" alt="" onclick="startCal.toggle();" /></div>
</div>
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Stop Displaying On:" AccessibleHeaderText="Date to stop displaying this clip.">
<ItemTemplate>
<% #Eval("EndDisplayDate", "{0:d}")%>
</ItemTemplate>
<EditItemTemplate>
<div class="base">
<div class="left">
<asp:TextBox ID="tbEndDate" Columns="10" MaxLength="10" Text='<%#Eval("EndDisplayDate", "{0:d}") %>'
runat="server"></asp:TextBox>
</div>
<div class="right">
<img style="height: 16px; width: 16px; border: 0" src="<%=GetSite() %>/img/cal.gif"
title="Select Date" alt="" onclick="endCal.toggle();" />
</div>
</div>
</EditItemTemplate>
<InsertItemTemplate>
<div class="base">
<div class="left">
<asp:TextBox ID="tbEndDate" Columns="10" MaxLength="10" runat="server"></asp:TextBox>
</div>
<div class="right">
<img style="height: 16px; width: 16px; border: 0" src="<%=GetSite() %>/img/cal.gif"
title="Select Date" alt="" onclick="endCal.toggle();" />
</div>
</div>
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Clip Text:" AccessibleHeaderText="Text that will be contained in the clip.">
<ItemTemplate>
<% #Eval("ItemDescriptiveText")%>
</ItemTemplate>
<EditItemTemplate>
<CE:Editor ID="tbClip"
width="600" MaxTextLength="4000"
height="500"
text='<%#Eval("ItemDescriptiveText")%>'
EditCompleteDocument="true"
AllowPasteHtml="false"
ThemeType="Office2003_BlueTheme"
runat="server">
</CE:Editor>
<br /> <span class="req">(R)</span> <span class="hints">(Unlimited text)</span>
<% --<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="tbClip" ErrorMessage="Clip Text Is Required" CssClass="req" />--%>
</EditItemTemplate>
<InsertItemTemplate>
<CE:Editor ID="tbClip"
width="600" MaxTextLength="4000"
height="500"
EditCompleteDocument="true"
AllowPasteHtml="false"
ThemeType="Office2003_BlueTheme"
runat="server">
</CE:Editor>
<br /> <span class="req">(R)</span> <span class="hints">(Unlimited text)</span>
<% --<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="tbClip" ErrorMessage="Clip Text Is Required" CssClass="req" />--%>
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Associate Page URL:" AccessibleHeaderText="URL to be associated with this text.">
<ItemTemplate>
<% #Eval("PageLink") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="tbPageLink" Text='<%#Eval("PageLink") %>' Columns="50" Rows="2"
MaxLength="100" TextMode="MultiLine" runat="server"></asp:TextBox>
<br />
<span class="hints">(100 characters maximum)</span>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="tbPageLink" Columns="50" Rows="2" MaxLength="100" TextMode="MultiLine"
runat="server"></asp:TextBox>
<br />
<span class="hints">(100 characters maximum)</span>
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Link Title Information:" AccessibleHeaderText="Title information for the Page URL.">
<ItemTemplate>
<% #Eval("PageLinkTitle") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="tbPageTitle" Text='<%#Eval("PageLinkTitle") %>' Columns="50" Rows="5"
MaxLength="250" TextMode="MultiLine" runat="server"></asp:TextBox>
<br />
<span class="hints">(250 characters maximum)</span>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="tbPageTitle" Columns="50" Rows="5" MaxLength="250" TextMode="MultiLine"
runat="server"></asp:TextBox>
<br />
<span class="hints">(250 characters maximum)</span>
</InsertItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="DateAdded" HeaderText="Date Added:" DataFormatString="{0:d}"
HtmlEncode="false" ReadOnly="true" />
<asp:BoundField DataField="AddedBy" HeaderText="Added By:" ReadOnly="true" />
<asp:CommandField ButtonType="Button" ShowEditButton="True" ShowInsertButton="True">
<ControlStyle CssClass="cmdbutton" />
</asp:CommandField>
</Fields>
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:NCDS %>"
DeleteCommand="DELETE FROM [AbilitiesTextClips] WHERE [Id] = @Id" InsertCommand="INSERT INTO [AbilitiesTextClips] ([EntryType], [StartDisplayDate], [EndDisplayDate], [ItemDescriptiveText], [PageLink], [PageLinkTitle], [DateAdded], [AddedBy]) VALUES (@EntryType, @StartDisplayDate, @EndDisplayDate, @ItemDescriptiveText, @PageLink, @PageLinkTitle, @DateAdded, @AddedBy)"
SelectCommand="SELECT [Id], [EntryType], [StartDisplayDate], [EndDisplayDate], [ItemDescriptiveText], [PageLink], [PageLinkTitle], [DateAdded], [AddedBy] FROM [AbilitiesTextClips] WHERE ([Id] = @Id)"
UpdateCommand="UPDATE [AbilitiesTextClips] SET [EntryType] = @EntryType, [StartDisplayDate] = @StartDisplayDate, [EndDisplayDate] = @EndDisplayDate, [ItemDescriptiveText] = @ItemDescriptiveText, [PageLink] = @PageLink, [PageLinkTitle] = @PageLinkTitle WHERE [Id] = @Id">
<SelectParameters>
<asp:ControlParameter ControlID="gvClips" Name="Id" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="Id" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="EntryType" Type="String" />
<asp:Parameter Name="StartDisplayDate" Type="DateTime" />
<asp:Parameter Name="EndDisplayDate" Type="DateTime" />
<asp:Parameter Name="ItemDescriptiveText" Type="String" />
<asp:Parameter Name="PageLink" Type="String" />
<asp:Parameter Name="PageLinkTitle" Type="String" />
<asp:Parameter Name="Id" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="EntryType" Type="String" />
<asp:Parameter Name="StartDisplayDate" Type="DateTime" />
<asp:Parameter Name="EndDisplayDate" Type="DateTime" />
<asp:Parameter Name="ItemDescriptiveText" Type="String" />
<asp:Parameter Name="PageLink" Type="String" />
<asp:Parameter Name="PageLinkTitle" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<div class="maintLink">
<asp:LinkButton ID="lbReturn" runat="server"><Return to the Clip List</asp:LinkButton>
</div>
</asp:Panel>
</div>
</form>
</div>
</div>
</div>
</ body>
</ html>
ASPX.VB code below:
Imports Common.Utility.Utils
Partial Class SysMaint_TextClipsMaintenance
Inherits System.Web.UI.Page
Dim slash As Char = ConfigurationManager.AppSettings("slash")
Dim GUID As HttpCookie
Dim row As DetailsViewRow = Nothing
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'incpMeta.FileName = Request.ServerVariables("Appl_Physical_Path") & ConfigurationManager.AppSettings("includeDir") & slash & _
'ConfigurationManager.AppSettings("abilitiesMetaInfo")
'INCPTopNav.FileName = Request.ServerVariables("Appl_Physical_Path") & ConfigurationManager.AppSettings("includeDir") & slash & _
'ConfigurationManager.AppSettings("defaultTopNav")
'INCPTopNav.UserType = Session.Item("UserType")
'INCPTopNav.SpecialTypes = ConfigurationManager.AppSettings("specialUsers")
'incpFooterNav.FileName = Request.ServerVariables("Appl_Physical_Path") & ConfigurationManager.AppSettings("includeDir") & slash & _
'ConfigurationManager.AppSettings("defaultFooterNav")
' get cookie
GUID = Request.Cookies( "GUID")
' no cookie called UID found - request one
Select Case IsDBNull(GUID) Or IsNothing(GUID)
Case True : GUID = AddCookie()
End Select
' First Time into the page for this session.
'Select Case Page.IsPostBack
' Case False
' ' No session information found.
' Select Case IsNothing(Session.Item("UserName"))
' Case True
' ' get the users information, if it is on the database
' Dim dtCreated, dtUpdated As Date
' Dim isOk As Boolean = False
' Dim SessionMgr As New SessionManagement.SessionManager
' SessionMgr.getSessionInfo(GUID.Value, dtCreated, dtUpdated, Session.Item("UserName"), _
' Session.Item("UserDisplayName"), Session.Item("UserType"), isOk)
' ' did we find them?
' Select Case isOk
' ' User has not logged in. Force them to login first.
' Case False
' Response.Redirect(getLoginRequest())
' End Select
' Case False
' Dim SessionMgr As New SessionManagement.SessionManager
' Dim isOk As Boolean = False
' SessionMgr.updateSessionInfo(GUID.Value, isOk)
' End Select
' ' insure that the user has permission to even be here.
' Select Case IsUserAuthorized(Session.Item("UserType"), ConfigurationManager.AppSettings("specialUsers"), GetCurrentPageName())
' Case False ' no authority. send to not authorized page
' Server.Transfer("../" & ConfigurationManager.AppSettings("notAuthorized"))
' End Select
' ' start by showing the listing
showListing()
'End Select
End Sub
' when the details link is clicked,
' hide the listing and show the details
Sub detailsSelected(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles gvClips.SelectedIndexChanged
If gvClips.SelectedRow IsNot Nothing Then
showDetails()
End If
End Sub
' when the return link is clicked,
' hide the details and show the listing.
Sub lbReturn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbReturn.Click
showListing()
End Sub
' show the listing and hide the details
Sub showListing()
pnlListing.Visible = True
pnlDetails.Visible = False
End Sub
' show the details and hide the listing
Sub showDetails()
pnlListing.Visible = False
pnlDetails.Visible = True
End Sub
' when a detail is deleted, rebind the listing
' and then show listing
Sub detailDeleted(ByVal sender As Object, _
ByVal e As DetailsViewDeletedEventArgs)
gvClips.DataBind()
showListing()
End Sub
' when an item has been inserted,
' rebuild the listing and show the listing
Sub itemInserted(ByVal sender As Object, _
ByVal e As DetailsViewInsertedEventArgs)
' Refresh the GridView control after a new record is inserted in
' the DetailsView control.
gvClips.DataBind()
dvClips.DataBind()
showListing()
End Sub
' before actually inserting, check to see if the input
' is valid first. if not, give user a message and cancel
' the insert.
Sub itemInserting(ByVal sender As Object, _
ByVal e As DetailsViewInsertEventArgs)
' Iterate though the values entered by the user and HTML encode
' the values. This helps prevent malicious values from being
' stored in the data source.
lblMesg.Text = Nothing
row = dvClips.Rows(0)
Dim fieldArray() As String = getFieldValues(row)
Dim err As Boolean = False
Dim ermsg As String = Nothing
' field length and inclusion checks
Select Case fieldArray(4).Length > 100
Case True
err = True
ermsg += "Page link may only be 100 characters long. Please correct<br />"
End Select
Select Case fieldArray(5).Length > 250
Case True
err = True
ermsg += "Page Link Title information may only be 250 characters long. Please correct<br />"
End Select
Select Case fieldArray(4).Length > 0
Case True
Select Case fieldArray(5).Length > 0
Case False
err = True
ermsg += "If a Page Link has been entered, this Title information must be entered.<br />"
End Select
Case False
Select Case fieldArray(5).Length > 0
Case True
err = True
ermsg += "No Page Link has been entered. Title information is invalid.<br />"
End Select
End Select
Select Case fieldArray(3).Length = 0
Case True
err = True
ermsg += "Descriptive text of the clip must be entered."
End Select
' If there is an error, do not complete the action.
Select Case err
Case True
e.Cancel = True
lblMesg.Text = ermsg
Case False
' check the date fields
Select Case IsNothing(fieldArray(1))
Case False ' starting date entered
Select Case IsNothing(fieldArray(2))
Case True ' no ending date entereed - prime date
fieldArray(2) = "12/13/9999"
End Select
Case True ' no starting date entered
Select Case IsNothing(fieldArray(2))
Case False ' ending date entered - prime starting as today
fieldArray(1) = Today.Date()
End Select
End Select
e.Values( "EntryType") = fieldArray(0)
e.Values( "StartDisplayDate") = fieldArray(1)
e.Values( "EndDisplayDate") = fieldArray(2)
e.Values( "ItemDescriptiveText") = fieldArray(3)
e.Values( "PageLink") = fieldArray(4)
e.Values( "PageLinkTitle") = fieldArray(5)
e.Values( "AddedBy") = Session.Item("UserName")
e.Values( "DateAdded") = Date.Now()
End Select
End Sub
' item updated, redisplay the udpated item.
Sub itemUpdated(ByVal sender As Object, _
ByVal e As DetailsViewUpdatedEventArgs)
' Refresh the GridView control after a new record is updated
' in the DetailsView control.
gvClips.DataBind()
dvClips.DataBind()
End Sub
' before the actual update, check the fields
' to insure they are valid. if not, send a message
' to the user and cancel the update.
Sub itemUpdating(ByVal sender As Object, _
ByVal e As DetailsViewUpdateEventArgs)
' Iterate though the values entered by the user and HTML encode
' the values. This helps prevent malicious values from being
' stored in the data source
lblMesg.Text = Nothing
row = dvClips.Rows(0)
Dim fieldArray() As String = getFieldValues(row)
Dim err As Boolean = False
Dim ermsg As String = Nothing
' field length and inclusion checks
Select Case fieldArray(4).Length > 100
Case True
err = True
ermsg += "Page link may only be 100 characters long. Please correct<br />"
End Select
Select Case fieldArray(5).Length > 250
Case True
err = True
ermsg += "Page Link Title information may only be 250 characters long. Please correct<br />"
End Select
Select Case fieldArray(4).Length > 0
Case True
Select Case fieldArray(5).Length > 0
Case False
err = True
ermsg += "If a Page Link has been entered, this Title information must be entered.<br />"
End Select
Case False
Select Case fieldArray(5).Length > 0
Case True
err = True
ermsg += "No Page Link has been entered. Title information is invalid."
End Select
End Select
Select Case fieldArray(3).Length = 0
Case True
err = True
ermsg += "Descriptive text of the clip must be entered."
End Select
' If there is an error, do not complete the action.
Select Case err
Case True
e.Cancel = True
lblMesg.Text = ermsg
Case False
' check the date fields
Select Case IsNothing(fieldArray(1))
Case False ' starting date entered
Select Case IsNothing(fieldArray(2))
Case True ' no ending date entereed - prime date
fieldArray(2) = "12/13/9999"
End Select
Case True ' no starting date entered
Select Case IsNothing(fieldArray(2))
Case False ' ending date entered - prime starting as today
fieldArray(1) = Today.Date()
End Select
End Select
e.NewValues( "EntryType") = fieldArray(0)
e.NewValues( "StartDisplayDate") = fieldArray(1)
e.NewValues( "EndDisplayDate") = fieldArray(2)
e.NewValues( "ItemDescriptiveText") = fieldArray(3)
e.NewValues( "PageLink") = fieldArray(4)
e.NewValues( "PageLinkTitle") = fieldArray(5)
End Select
End Sub
Function getFieldValues(ByVal row As DetailsViewRow) As Array
Dim valArray(6) As String
Dim ddl1 As DropDownList = CType(row.FindControl("ddlET"), DropDownList)
valArray(0) = ddl1.SelectedValue()
Dim c0 As TextBox = CType(row.FindControl("tbStartDate"), TextBox)
valArray(1) = c0.Text()
Dim c1 As TextBox = CType(row.FindControl("tbEndDate"), TextBox)
valArray(2) = c1.Text()
Dim ftb1 As TextBox = CType(row.FindControl("tbClip"), TextBox)
valArray(3) = ftb1.Text()
Dim tb0 As TextBox = CType(row.FindControl("tbPageLink"), TextBox)
valArray(4) = tb0.Text()
Dim tb1 As TextBox = CType(row.FindControl("tbPageTitle"), TextBox)
valArray(5) = tb1.Text()
Return valArray
End Function
' apply hilights to the keywords
Protected Sub convertType(ByVal sender As Object, ByVal e As EventArgs)
Select Case sender.text
Case Is = "A"
sender.text = "Awards & Projects"
Case Is = "S"
sender.Text = "Special Announcements"
End Select
End Sub
End Class
Any help would be welcome.
Tom
|
|