formview insert

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>
 
K

Kushi

Hi,

I have given the code which inserts the value to the database.

<asp:formview id="AuthFormView"
datasourceid="SqlDataSource1"
allowpaging="True"
datakeynames="Employeeid"
runat="server">
<itemtemplate>
<table>
<tr>
<td><b>FirstName:</b></td>
<td><%# Eval("FirstName") %></td>
</tr>

<tr>
<td><b>LastName:</b></td>
<td><%# Eval("LastName") %></td>
</tr>

<tr>
<td colspan="2">
<asp:Button id="NewButton"
text="New"
commandname="New"
runat="server"/>
</td>
</tr>
</table>
</itemtemplate>
<insertitemtemplate>
<table>
<tr>
<td><b>FirstName:</b></td>
<td>
<asp:textbox id="FirstNameInsertTextBox"
text='<%# Bind("FirstName") %>'
runat="server"/>
</td>
</tr>
<tr>
<td><b>LastName:</b></td>
<td>
<asp:textbox id="Textbox1"
text='<%# Bind("LastName") %>'
runat="server"/></td>
</tr>
<tr>
<td colspan="2">
<asp:Button id="InsertButton"
text="Insert"
commandname="Insert"
runat="server"/>
<asp:Button id="CancelButton"
text="Cancel"
commandname="Cancel"
runat="server"/>
</td>
</tr>
</table>
</insertitemtemplate>
</asp:formview>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString2 %>"
SelectCommand="SELECT [EmployeeID], [LastName], [FirstName]
FROM [Employees]" InsertCommand=" Insert Into [Employees] ([LastName],
[FirstName]) VALUES (@LastName, @FirstName)" ></asp:SqlDataSource>


Thanks
Sharmila
(www.syncfusion.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top