Sorry, I forgot to paste the code. Here it is.
<form id="form1" runat="server">
<div>
<asp:FormView ID="FormView1" runat="server" AllowPaging="Tr ue"
DataKeyNames="P KId"
DataSourceID="S qlDataSource1">
<PagerSetting s Mode="NumericFi rstLast" />
<EditItemTempla te>
PKId:
<asp:Label ID="PKIdLabel1 " runat="server" Text='<%# Eval("PKId")
%>'></asp:Label><br />
Name:
<asp:TextBox ID="NameTextBox " runat="server" Text='<%# Bind("Name") %>'>
</asp:TextBox><br />
Description:
<asp:TextBox ID="Description TextBox" runat="server" Text='<%#
Bind("Descripti on") %>'>
</asp:TextBox><br />
ItemNum:
<asp:TextBox ID="ItemNumText Box" runat="server" Text='<%#
Bind("ItemNum") %>'>
</asp:TextBox><br />
Modified:
<asp:TextBox ID="ModifiedTex tBox" runat="server" Text='<%#
Bind("Modified" ) %>'>
</asp:TextBox><br />
<asp:LinkButt on ID="UpdateButto n" runat="server"
CausesValidatio n="True" CommandName="Up date"
Text="Update">
</asp:LinkButton>
<asp:LinkButt on ID="UpdateCance lButton" runat="server"
CausesValidatio n="False" CommandName="Ca ncel"
Text="Cancel">
</asp:LinkButton>
</EditItemTemplat e>
<InsertItemTemp late>
Name:
<asp:TextBox ID="NameTextBox " runat="server" Text='<%# Bind("Name") %>'>
</asp:TextBox><br />
Description:
<asp:TextBox ID="Description TextBox" runat="server" Text='<%#
Bind("Descripti on") %>'>
</asp:TextBox><br />
ItemNum:
<asp:TextBox ID="ItemNumText Box" runat="server" Text='<%#
Bind("ItemNum") %>'>
</asp:TextBox><br />
Modified:
<asp:TextBox ID="ModifiedTex tBox" runat="server" Text='<%#
Bind("Modified" ) %>'>
</asp:TextBox><br />
<asp:LinkButt on ID="InsertButto n" runat="server"
CausesValidatio n="True" CommandName="In sert"
Text="Insert">
</asp:LinkButton>
<asp:LinkButt on ID="InsertCance lButton" runat="server"
CausesValidatio n="False" CommandName="Ca ncel"
Text="Cancel">
</asp:LinkButton>
</InsertItemTempl ate>
<ItemTemplate >
PKId:
<asp:Label ID="PKIdLabel" runat="server" Text='<%# Eval("PKId")
%>'></asp:Label><br />
Name:
<asp:Label ID="NameLabel" runat="server" Text='<%# Bind("Name")
%>'></asp:Label><br />
Description:
<asp:Label ID="Description Label" runat="server" Text='<%#
Bind("Descripti on") %>'>
</asp:Label><br />
ItemNum:
<asp:Label ID="ItemNumLabe l" runat="server" Text='<%# Bind("ItemNum")
%>'></asp:Label><br />
Modified:
<asp:Label ID="ModifiedLab el" runat="server" Text='<%# Bind("Modified" )
%>'></asp:Label><br />
<asp:LinkButt on ID="EditButton " runat="server" CausesValidatio n="False"
CommandName="Ed it"
Text="Edit">
</asp:LinkButton>
<asp:LinkButt on ID="DeleteButto n" runat="server"
CausesValidatio n="False" CommandName="De lete"
Text="Delete">
</asp:LinkButton>
<asp:LinkButt on ID="NewButton" runat="server" CausesValidatio n="False"
CommandName="Ne w"
Text="New">
</asp:LinkButton>
</ItemTemplate>
</asp:FormView>
</div>
<asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:DataNozzleOr gConnectionStri ng %>"
DeleteCommand=" aaTableDelete" DeleteCommandTy pe="StoredProce dure"
InsertCommand=" aaTableInsert"
InsertCommandTy pe="StoredProce dure" SelectCommand=" aaTableSelectAl l"
SelectCommandTy pe="StoredProce dure"
UpdateCommand=" aaTableUpdate" UpdateCommandTy pe="StoredProce dure">
<DeleteParamete rs>
<asp:Paramete r Name="PKId" Type="Decimal" />
</DeleteParameter s>
<UpdateParamete rs>
<asp:ControlPar ameter ControlID="Form View1" Name="PKId"
PropertyName="S electedValue"
Type="Decimal" />
<asp:ControlPar ameter ControlID="Form View1" Name="Name"
PropertyName="S electedValue"
Type="String" />
<asp:ControlPar ameter ControlID="Form View1" Name="Descripti on"
PropertyName="S electedValue"
Type="String" />
<asp:ControlPar ameter ControlID="Form View1" Name="ItemNum"
PropertyName="S electedValue"
Type="Decimal" />
<asp:ControlPar ameter ControlID="Form View1" Name="Modified"
PropertyName="S electedValue"
Type="DateTime" />
</UpdateParameter s>
<InsertParamete rs>
<asp:ControlPar ameter ControlID="Form View1" Direction="Inpu tOutput"
Name="PKId" PropertyName="S electedValue"
Type="Decimal" />
<asp:ControlPar ameter ControlID="Form View1" Name="Name"
PropertyName="S electedValue"
Type="String" />
<asp:ControlPar ameter ControlID="Form View1" Name="Descripti on"
PropertyName="S electedValue"
Type="String" />
<asp:ControlPar ameter ControlID="Form View1" Name="ItemNum"
PropertyName="S electedValue"
Type="Decimal" />
<asp:Paramete r Direction="Retu rnValue" Name="RETURN_VA LUE" Type="Int32"
/>
<asp:ControlPar ameter ControlID="Form View1" Name="Modified"
PropertyName="S electedValue"
Type="DateTime" />
</InsertParameter s>
</asp:SqlDataSour ce>
</form>
--
BabuMan
"BabuMan" wrote:
Hi,
I have a FormView control on a page which is bound to a SQLDataSource table.
Everything works fine except for the "Update". I get an
InvalidCastExce ption. The problem only seems to surface when I have a
'datetime' column in the table. I tested this with a very simple sample
table. As long as there is no datetime column either in the table or on the
form, all are peachy. Here is the code, in case somebody can figure it out.
I would really appreciate a post if you know a solution.
--
BabuMan