C
Chris
I have a formview based on an SQL Data Source see below. I have a formview
bound to it. The item insert template has a command button with a command
name insert. When I press it the insert doesn't take place in the database.
What obvious thing am I doing wrong!!? Regards, Chris. Could it be something
to do with the FormView1_ItemInserted event.
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$
ConnectionStrings:Balaces_JLK %>"
InsertCommand="INSERT INTO tblBalanceGroups(CompanyID, Description,
OpeningBalance) VALUES (@CompanyID, @Description, @OpeningBalance)"
SelectCommand="SELECT [BalanceGroupID], [CompanyID], [Description],
[OpeningBalance] FROM [tblBalanceGroups] WHERE ([CompanyID] = @CompanyID)">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="CompanyID"
PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<InsertItemTemplate>
<table>
<tr>
<td style="width: 140px">
Description</td>
<td style="width: 167px">
<asp:TextBox ID="txtDescription" runat="server" Text="<%#
Bind('Description') %>"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 140px">
Opening Balance</td>
<td style="width: 167px">
<asp:TextBox ID="txtOpen" runat="server" Text="<%# Bind('OpeningBalance')
%>"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 140px">
<asp:HiddenField ID="HiddenField1" runat="server" Value="<%#
Bind('CompanyID') %>" />
</td>
<td style="width: 167px">
<asp:Button ID="Button1" runat="server" CommandName="insert"
Text="Button" />
<asp:Button ID="Button2" runat="server" CommandName="cancel" Text="Button"
/>
</td>
</tr>
</table>
</InsertItemTemplate>
</asp:FormView>
bound to it. The item insert template has a command button with a command
name insert. When I press it the insert doesn't take place in the database.
What obvious thing am I doing wrong!!? Regards, Chris. Could it be something
to do with the FormView1_ItemInserted event.
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$
ConnectionStrings:Balaces_JLK %>"
InsertCommand="INSERT INTO tblBalanceGroups(CompanyID, Description,
OpeningBalance) VALUES (@CompanyID, @Description, @OpeningBalance)"
SelectCommand="SELECT [BalanceGroupID], [CompanyID], [Description],
[OpeningBalance] FROM [tblBalanceGroups] WHERE ([CompanyID] = @CompanyID)">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="CompanyID"
PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<InsertItemTemplate>
<table>
<tr>
<td style="width: 140px">
Description</td>
<td style="width: 167px">
<asp:TextBox ID="txtDescription" runat="server" Text="<%#
Bind('Description') %>"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 140px">
Opening Balance</td>
<td style="width: 167px">
<asp:TextBox ID="txtOpen" runat="server" Text="<%# Bind('OpeningBalance')
%>"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 140px">
<asp:HiddenField ID="HiddenField1" runat="server" Value="<%#
Bind('CompanyID') %>" />
</td>
<td style="width: 167px">
<asp:Button ID="Button1" runat="server" CommandName="insert"
Text="Button" />
<asp:Button ID="Button2" runat="server" CommandName="cancel" Text="Button"
/>
</td>
</tr>
</table>
</InsertItemTemplate>
</asp:FormView>