Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi all:
 
I write this code :
<asp:UpdatePanel ID="UpdatePanel2" runat="server" Visible="False" ChildrenAsTriggers="true" UpdateMode="Conditional">
                        <ContentTemplate>
 
                            <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" CellPadding="2" DataSourceID="SqlDataSource2" ForeColor="Black" GridLines="None" Height="50px" Width="350px" EmptyDataText="There is no data in your profile..." AutoGenerateRows="False" DataKeyNames="product_id" AutoGenerateDeleteButton="True">
                                <AlternatingRowStyle BackColor="PaleGoldenrod" />
                                <EditRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
                                <Fields>
                                    <asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />
                                    <asp:BoundField DataField="category" HeaderText="category" SortExpression="category" />
                                    <asp:BoundField DataField="product_id" HeaderText="product_id" InsertVisible="False" ReadOnly="True" SortExpression="product_id" />
                                    <asp:HyperLinkField DataNavigateUrlFields="product_id" DataNavigateUrlFormatString="~/ProductDetailes.aspx?product_id={0}" DataTextField="product_id" DataTextFormatString="Click to see product detailes.." />
                                </Fields>
 
                                <FooterStyle BackColor="Tan" />
                                <HeaderStyle BackColor="Tan" Font-Bold="True" />
                                <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
                            </asp:DetailsView>
 
                            <br />
                        </ContentTemplate>
 
                    </asp:UpdatePanel>
 
but when i hit delete it doesn't work , it requires a trigger but i don't know it ..
 
any help please for the Insert,Update,Delete triggers will be appreciated
Posted 18-Apr-13 14:21pm
Edited 18-Apr-13 14:22pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
       UpdateCommand="Update Products SET name=@name,category=@category WHERE product_id=@product_id"
       InsertCommand="INSERT INTO Products(name,category,product_id) VALUES (@name,@category,@product_id)"
       DeleteCommand="DELETE FROM [Products] WHERE product_id=@product_id;" SelectCommand="SELECT * FROM [Products]">
       <InsertParameters>
           <asp:Parameter Name="name" />
           <asp:Parameter Name="category" />
           <asp:Parameter Name="product_id" />
       </InsertParameters>
   </asp:SqlDataSource>
  Permalink  
v2
Comments
Al-Najjar Ali Moh'd at 19-Apr-13 14:02pm
   
Thank you very much :) , now it works ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web01 | 2.8.1411022.1 | Last Updated 19 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100