473,700 Members | 2,763 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Details View doesnt work with Delete Or Update

JustRun
127 New Member
I have a problem with the select option at the gridview and gonna pull my hair out cause it doesn't work at all.
Here is the Grid view code: I want to get the selected row when the user click "Select"
I think it might related to the database Table !!

Expand|Select|Wrap|Line Numbers
  1. <asp:SqlDataSource ID="sdsCustomer" runat="server" ConflictDetection="CompareAllValues"
  2.                         ConnectionString="Data Source=.;Initial Catalog=TimeSheet;Integrated Security=True"
  3.                         DeleteCommand="DELETE FROM [CustomerTable] WHERE [DocumentID] = @original_DocumentID AND [CustomerName] = @original_CustomerName AND [Phone] = @original_Phone AND [Phone2] = @original_Phone2 AND [Phone3] = @original_Phone3 AND [Address] = @original_Address AND [Fax] = @original_Fax AND [email] = @original_Email AND [Representetive] = @original_Representetive AND [DomainName] = @original_DomainName AND [RenewDate] = @original_RenewDate AND [CompanyActivity] = @original_CompanyActivity AND [HowToRecognize] = @original_HowToRecognize"
  4.                         InsertCommand="INSERT INTO [CustomerTable] ([CustomerName], [Phone], [Phone2], [Phone3], [Address], [Fax], [email], [Representetive], [DomainName], [RenewDate], [CompanyActivity], [HowToRecognize]) VALUES (@CustomerName, @Phone, @Phone2, @Phone3, @Address, @Fax, @Email, @Representetive, @DomainName, @RenewDate, @CompanyActivity, @HowToRecognize)"
  5.                         OldValuesParameterFormatString="original_{0}" OnUpdated="sdsAllCustomers_Updated"
  6.                         ProviderName="System.Data.SqlClient" SelectCommand="SELECT [DocumentID], [CustomerName], [Phone], [Phone2], [Phone3], [Address], [Fax], [email], [Representetive], [DomainName], [RenewDate], [CompanyActivity], [HowToRecognize] FROM [CustomerTable] ORDER BY [CustomerName]"
  7.                         UpdateCommand="UPDATE [CustomerTable] SET [CustomerName] = @CustomerName, [Phone] = @Phone, [Phone2] = @Phone2, [Phone3] = @Phone3, [Address] = @Address, [Fax] = @Fax, [email] = @Email, [Representetive] = @Representetive, [DomainName] = @DomainName, [RenewDate] = @RenewDate, [CompanyActivity] = @CompanyActivity, [HowToRecognize] = @HowToRecognize WHERE [DocumentID] = @original_DocumentID AND [CustomerName] = @original_CustomerName AND [Phone] = @original_Phone AND [Phone2] = @original_Phone2 AND [Phone3] = @original_Phone3 AND [Address] = @original_Address AND [Fax] = @original_Fax AND [email] = @original_Email AND [Representetive] = @original_Representetive AND [DomainName] = @original_DomainName AND [RenewDate] = @original_RenewDate AND [CompanyActivity] = @original_CompanyActivity AND [HowToRecognize] = @original_HowToRecognize">
  8.                         <DeleteParameters>
  9.                             <asp:Parameter Name="original_DocumentID" Type="Object" />
  10.                             <asp:Parameter Name="original_CustomerName" Type="String" />
  11.                             <asp:Parameter Name="original_Phone" Type="String" />
  12.                             <asp:Parameter Name="original_Phone2" Type="String" />
  13.                             <asp:Parameter Name="original_Phone3" Type="String" />
  14.                             <asp:Parameter Name="original_Address" Type="String" />
  15.                             <asp:Parameter Name="original_Fax" Type="String" />
  16.                             <asp:Parameter Name="original_Email" Type="String" />
  17.                             <asp:Parameter Name="original_Representetive" Type="String" />
  18.                             <asp:Parameter Name="original_DomainName" Type="String" />
  19.                             <asp:Parameter Name="original_RenewDate" Type="String" />
  20.                             <asp:Parameter Name="original_CompanyActivity" Type="String" />
  21.                             <asp:Parameter Name="original_HowToRecognize" Type="String" />
  22.                         </DeleteParameters>
  23.                         <UpdateParameters>
  24.                             <asp:Parameter Name="CustomerName" Type="String" />
  25.                             <asp:Parameter Name="Phone" Type="String" />
  26.                             <asp:Parameter Name="Phone2" Type="String" />
  27.                             <asp:Parameter Name="Phone3" Type="String" />
  28.                             <asp:Parameter Name="Address" Type="String" />
  29.                             <asp:Parameter Name="Fax" Type="String" />
  30.                             <asp:Parameter Name="Email" Type="String" />
  31.                             <asp:Parameter Name="Representetive" Type="String" />
  32.                             <asp:Parameter Name="DomainName" Type="String" />
  33.                             <asp:Parameter Name="RenewDate" Type="String" />
  34.                             <asp:Parameter Name="CompanyActivity" Type="String" />
  35.                             <asp:Parameter Name="HowToRecognize" Type="String" />
  36.                             <asp:Parameter Name="original_DocumentID" Type="Object" />
  37.                             <asp:Parameter Name="original_CustomerName" Type="String" />
  38.                             <asp:Parameter Name="original_Phone" Type="String" />
  39.                             <asp:Parameter Name="original_Phone2" Type="String" />
  40.                             <asp:Parameter Name="original_Phone3" Type="String" />
  41.                             <asp:Parameter Name="original_Address" Type="String" />
  42.                             <asp:Parameter Name="original_Fax" Type="String" />
  43.                             <asp:Parameter Name="original_Email" Type="String" />
  44.                             <asp:Parameter Name="original_Representetive" Type="String" />
  45.                             <asp:Parameter Name="original_DomainName" Type="String" />
  46.                             <asp:Parameter Name="original_RenewDate" Type="String" />
  47.                             <asp:Parameter Name="original_CompanyActivity" Type="String" />
  48.                             <asp:Parameter Name="original_HowToRecognize" Type="String" />
  49.                         </UpdateParameters>
  50.                         <InsertParameters>
  51.                             <asp:Parameter Name="CustomerName" Type="String" />
  52.                             <asp:Parameter Name="Phone" Type="String" />
  53.                             <asp:Parameter Name="Phone2" Type="String" />
  54.                             <asp:Parameter Name="Phone3" Type="String" />
  55.                             <asp:Parameter Name="Address" Type="String" />
  56.                             <asp:Parameter Name="Fax" Type="String" />
  57.                             <asp:Parameter Name="Email" Type="String" />
  58.                             <asp:Parameter Name="Representetive" Type="String" />
  59.                             <asp:Parameter Name="DomainName" Type="String" />
  60.                             <asp:Parameter Name="RenewDate" Type="String" />
  61.                             <asp:Parameter Name="CompanyActivity" Type="String" />
  62.                             <asp:Parameter Name="HowToRecognize" Type="String" />
  63.                         </InsertParameters>
  64.                     </asp:SqlDataSource>
  65.                     <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="528px" AllowPaging="True" AutoGenerateRows="False" DataKeyNames="DocumentID" DataSourceID="sdsCustomer">
  66.                         <Fields>
  67.                             <asp:BoundField DataField="DocumentID" HeaderText="DocumentID" ReadOnly="True" SortExpression="DocumentID" />
  68.                             <asp:BoundField DataField="CustomerName" HeaderText="CustomerName" SortExpression="CustomerName" />
  69.                             <asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" />
  70.                             <asp:BoundField DataField="Phone2" HeaderText="Phone2" SortExpression="Phone2" />
  71.                             <asp:BoundField DataField="Phone3" HeaderText="Phone3" SortExpression="Phone3" />
  72.                             <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
  73.                             <asp:BoundField DataField="Fax" HeaderText="Fax" SortExpression="Fax" />
  74.                             <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
  75.                             <asp:BoundField DataField="Representetive" HeaderText="Representetive" SortExpression="Representetive" />
  76.                             <asp:BoundField DataField="DomainName" HeaderText="DomainName" SortExpression="DomainName" />
  77.                             <asp:BoundField DataField="RenewDate" HeaderText="RenewDate" SortExpression="RenewDate" />
  78.                             <asp:BoundField DataField="CompanyActivity" HeaderText="CompanyActivity" SortExpression="CompanyActivity" />
  79.                             <asp:BoundField DataField="HowToRecognize" HeaderText="HowToRecognize" SortExpression="HowToRecognize" />
  80.                             <asp:TemplateField ShowHeader="False">
  81.                                 <EditItemTemplate>
  82.                                     <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
  83.                                         Text="Update"></asp:LinkButton>
  84.                                     <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
  85.                                         Text="Cancel"></asp:LinkButton>
  86.                                 </EditItemTemplate>
  87.                                 <InsertItemTemplate>
  88.                                     <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Insert"
  89.                                         Text="Insert"></asp:LinkButton>
  90.                                     <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
  91.                                         Text="Cancel"></asp:LinkButton>
  92.                                 </InsertItemTemplate>
  93.                                 <ItemTemplate>
  94.                                     <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
  95.                                         Text="Edit"></asp:LinkButton>
  96.                                     <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="New"
  97.                                         Text="New"></asp:LinkButton>
  98.                                     <asp:LinkButton ID="LinkButton3" runat="server" CausesValidation="False" CommandName="Delete"
  99.                                         Text="Delete"></asp:LinkButton>
  100.                                 </ItemTemplate>
  101.                             </asp:TemplateField>
  102.                         </Fields>
  103.                     </asp:DetailsView>
  104.  
Expand|Select|Wrap|Line Numbers
  1.     protected void sdsAllCustomers_Updated(object sender, SqlDataSourceStatusEventArgs e)
  2.     {
  3.         lblErr.Visible = true;
  4.         if (e.Exception != null)
  5.         {
  6.             lblErr.Text = e.Exception.Message;
  7.             e.ExceptionHandled = true;
  8.         }
  9.         else
  10.         {
  11.             lblErr.Text = "Your data have been modified successfuly";
  12.         }
  13.     }
  14.  
  15. Any Help Please
  16.  
Oct 1 '08 #1
1 1590
MrMancunian
569 Recognized Expert Contributor
So...Are you going to post a question or is this just to notify us that you have a problem? In the last case: "Your problem has been noted. Have a nice day".
Oct 3 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
2321
by: btober | last post by:
I'm finding that column defaults are not being assigned to nulls when I do an insert by way of a an ON INSERT rule on a view. For example, the following script \set ON_ERROR_STOP ON \c template1 --DROP DATABASE testdb; CREATE DATABASE testdb; \c testdb
0
1818
by: Palle Girgensohn | last post by:
Hi! A performance question: I have some tables: Tabell "public.person" Kolumn | Typ | Modifierare ------------------+--------------------------+--------------- userid | text | not null
1
1799
by: Shiva | last post by:
Hi, My (main)form has a subform that contains the details of the mainform. The default view of the mainform is 'single form', the default view of the subform containing the details is 'Datasheet' - Datasheet displays the data of the associated table as a grid. I want both the mainform (the master) and the subform to be displayed as grid. But after changing the default view of the mainform to 'datasheet', the subform disappears...
2
1819
by: Peter Gebauer | last post by:
Hello. This section works fine: CREATE TABLE torder ( id INT8 NOT NULL PRIMARY KEY ); CREATE TABLE torder_row ( id INT8 NOT NULL PRIMARY KEY,
1
2433
by: SVGK, Raju | last post by:
Hi, I have a table where in lot of triggers were included in that as shown below. How to view/access triggers and procedures from postgresql. I am using postgresql 7.4.1 on solaris. regds -raju
3
1717
by: gaDev | last post by:
1) I build a Html Table dynamically (Header Row, and then 2 rows with data All 2 rows have 2 cells: cell(0) contains a delete button (ASP Button), cell(1) contains a HTML Text box 2) On Form Load and get some data from a dataset and then from it's contents build the page At this point the page is rendered and 2 rows are displayed. There is an Add button that a user can click to add another row to the table. This works fine and the row...
0
1638
by: DC | last post by:
How can I update data using a Details view without using an AccessDataSource and its associated Insert, Update and Delete but using a DataReader instead?
8
1491
by: jasone | last post by:
Hi all, im nearly there with this one and im sure it shouldnt be hard to solve, i just cant seem to find the solution. ive got records being displayed, the user can then tick what records to delete... click delete.. it shows deleted records then you can go back to the screen, It works if one record is selected but any more it doesnt delete any so im sure there is a problem with my SQL statement. the code for the 2 pages have been shown...
3
3098
by: =?Utf-8?B?S2F5xLFoYW4=?= | last post by:
In my project,i added datagridview to my form , i transfered my table to datagridview and added multiple rows and when i called dataadapther.update ,,result is ok. But when i tried it for the delete operations,i got the error like "set primary key in your table" ,,i want delete multiple rows from Datatable which doesnt contain primary key
0
8722
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
8643
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
9069
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8968
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
8922
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7805
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...
0
4401
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...
2
2389
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2025
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.