473,796 Members | 2,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_ItemI nserted event.

<asp:SqlDataSou rce ID="SqlDataSour ce2" runat="server" ConnectionStrin g="<%$
ConnectionStrin gs:Balaces_JLK %>"

InsertCommand=" INSERT INTO tblBalanceGroup s(CompanyID, Description,
OpeningBalance) VALUES (@CompanyID, @Description, @OpeningBalance )"

SelectCommand=" SELECT [BalanceGroupID], [CompanyID], [Description],
[OpeningBalance] FROM [tblBalanceGroup s] WHERE ([CompanyID] = @CompanyID)">

<SelectParamete rs>

<asp:ControlPar ameter ControlID="Drop DownList1" Name="CompanyID "
PropertyName="S electedValue"

Type="Int32" />

</SelectParameter s>

</asp:SqlDataSour ce>

<InsertItemTemp late>

<table>

<tr>

<td style="width: 140px">

Description</td>

<td style="width: 167px">

<asp:TextBox ID="txtDescript ion" runat="server" Text="<%#
Bind('Descripti on') %>"></asp:TextBox></td>

</tr>

<tr>

<td style="width: 140px">

Opening Balance</td>

<td style="width: 167px">

<asp:TextBox ID="txtOpen" runat="server" Text="<%# Bind('OpeningBa lance')
%>"></asp:TextBox></td>

</tr>

<tr>

<td style="width: 140px">

<asp:HiddenFiel d ID="HiddenField 1" runat="server" Value="<%#
Bind('CompanyID ') %>" />

</td>

<td style="width: 167px">

<asp:Button ID="Button1" runat="server" CommandName="in sert"

Text="Button" />

<asp:Button ID="Button2" runat="server" CommandName="ca ncel" Text="Button"
/>

</td>

</tr>

</table>

</InsertItemTempl ate>

</asp:FormView>
Jun 26 '06 #1
1 1577

Hi,

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

<asp:formview id="AuthFormVie w"
datasourceid="S qlDataSource1"
allowpaging="Tr ue"
datakeynames="E mployeeid"
runat="server">
<itemtemplate >
<table>
<tr>
<td><b>FirstNam e:</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="Ne w"
runat="server"/>
</td>
</tr>
</table>
</itemtemplate>
<insertitemtemp late>
<table>
<tr>
<td><b>FirstNam e:</b></td>
<td>
<asp:textbox id="FirstNameIn sertTextBox"
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="InsertButto n"
text="Insert"
commandname="In sert"
runat="server"/>
<asp:Button id="CancelButto n"
text="Cancel"
commandname="Ca ncel"
runat="server"/>
</td>
</tr>
</table>
</insertitemtempl ate>
</asp:formview>

<asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:NorthwindCon nectionString2 %>"
SelectCommand=" SELECT [EmployeeID], [LastName], [FirstName]
FROM [Employees]" InsertCommand=" Insert Into [Employees] ([LastName],
[FirstName]) VALUES (@LastName, @FirstName)" ></asp:SqlDataSour ce>
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
6044
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 "LabLocation_ID". With an existing lab, they then need to add the members for that lab. So, what I am trying to do is the following. With the FormView of the Lab open, the user will click a button to open a FormView (InsertMode) and add a new...
7
4353
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 sqldatasource of the formview. If i put this textboxes outside the table everything works well, but as soon as i put them inside the table (in order to organize the layout in the right way) they doesn't work. They works only as eval() and not bind()...
2
2156
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" then a GridView opens up and they can then select a record to view the record in the FormView. If they select the "NewRecord" LinkButton, the same FormView opens in Insert mode. The problem that I am having is that when the user clicks the...
1
3891
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 and a FormView on the same page, where the GridView is visible at page load, and the FormView is set to Edit mode by default, but is hidden on the page. I have the Select link enabled on my GridView, and I use the SelectedIndexChanged event to hide...
2
2775
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 all can address to help me understand events with these better. I've been reading up on inserted/inserting also deleted/deleting, but where is it better to run call those events from via formview or datasource? Also, I have been trying to...
4
4698
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 in the ItemCommand event but I can't redirect from here because the ItemUpdated event hasn't fired yet. I can put a variable in the code-behind class which is gets the
0
3588
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 OleDbParameterCollection" whenI try to write a new record. Delete and Modify work fine its just the add record function causes the error.
2
2388
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
4342
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, one in the EditItemTemplate and one in the InsertItemTemplate. Each of those Multiviews contains several Views, and each view contains several controls such as textboxes, checkboxes etc. Those controls are bound to the Formview's datasource, which...
8
11972
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 which is not a string, for example a custom type Address which contains properties such as StreetAddress, City, County, Country etc how do i bind to those properties on the same form view? I have tried doing Bind("Address.StreetAddress") but...
0
9680
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9528
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10456
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10174
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9052
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7548
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6788
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5442
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2926
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.