473,378 Members | 1,468 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,378 software developers and data experts.

Details View doesnt work with Delete Or Update

JustRun
127 100+
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 1562
MrMancunian
569 Expert 512MB
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
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...
0
by: Palle Girgensohn | last post by:
Hi! A performance question: I have some tables: Tabell "public.person" Kolumn | Typ | Modifierare ------------------+--------------------------+---------------...
1
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...
2
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
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...
3
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...
0
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
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...
3
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.