473,405 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

formview insert

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>
Jun 26 '06 #1
1 1563

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)

Jun 27 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: sck10 | last post by:
Hello, I am creating a form for users to enter information about a lab and the members of the lab. I have one form (FormView) that they use to enter information about that lab. The keyvalue is...
7
by: Lorenzino | last post by:
Hi, I have a problem with bindings in a formview. I have a formview; in the insert template i've created a wizard control and inside it i have an HTML table with some textboxes bound to the...
2
by: sck10 | last post by:
Hello, I have a LinkButton that I use to open a FormView in ReadOnly mode "ShowList", and a LinkButton to open the same FormView in the Insert mode "NewRecord". If the user clicks "ShowList"...
1
by: scartin | last post by:
I'm fairly new to working with ASP web controls, and am running into what seems to be a ridiculous problem that I'm hoping will be a breeze for an experienced ASP developer. I have a GridView...
2
by: Kelly | last post by:
I'm fairly new to ASP.NET2, but I have an ASP 3.0 background, and I've been experimenting with the DataSource and FormView widgets. I wound up having some questions along the way which I hope you...
4
by: J055 | last post by:
Hi I have 2 update buttons in my FormView ('Apply' and 'OK'). I want both buttons to update the data source but the 'OK' button should redirect afterwards. I can see which button is clicked...
0
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this...
2
by: sck10 | last post by:
Hello, I have 3 objects: LinkButton GridView FormView The LinkButton is used to open the FormView in Insert mode. The GridView provides a list of products. When the "Select" link is
1
by: Trev | last post by:
Hi, I'm hoping that someone in this group can shed some light on an issue I'm having with a Formview. I have a Web User Control (.ascx) with a Formview. The Formview contains 2 Multiviews,...
8
by: =?Utf-8?B?QXNo?= | last post by:
Hi, I have an object, for example User. User contains various properties which i have been able to bind to successfully using wizards and the form view. However if the class User has a property...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.