Click here to Skip to main content
15,868,292 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all:

I write this code :
XML
<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
Updated 18-Apr-13 13:22pm
v2

1 solution

XML
<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>
 
Share this answer
 
v2
Comments
ALNAJJARALI 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900