UpdatePanel中DetailesView的Insert,Update,Delete触发器是什么 [英] what is the Insert,Update,Delete triggers for DetailesView in UpdatePanel

查看:120
本文介绍了UpdatePanel中DetailesView的Insert,Update,Delete触发器是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好:



我写这段代码:

 <   asp:UpdatePanel     ID   =  UpdatePanel2    runat   =  server   可见  =  False    ChildrenAsTriggers   =   true    UpdateMode  < span class =code-keyword> = 条件 >  
< ContentTemplate >

< asp:DetailsView < span class =code-attribute> ID = DetailsView1 runat = server AllowPaging = True BackColor = LightGoldenrodYellow BorderColor = Tan BorderWidth = 1px CellPadding = < span class =code-keyword> 2 DataSourceID = SqlDataSource2 ForeColor = 黑色 GridLines = 高度 = 50px 宽度 = 350px EmptyDataText = 您的个人资料中没有数据... AutoGenerateRows = False DataKeyNames = product_id AutoGenerateDeleteButton = True >
< AlternatingRowStyle BackColor = PaleGoldenrod / >
< EditRowStyle BackColor = DarkSlateBlue ForeColor = GhostWhite / >
< 字段 >
< asp:BoundField DataField < span class =code-keyword> =
name HeaderText = name SortExpression = name / >
< asp:BoundField < span class =code-att ribute> DataField = category HeaderText = category SortExpression = 类别 / >
< asp:BoundField DataField = product_id HeaderText = product_id InsertVisible = False ReadOnly = True SortExpression = product_id < span class =code-keyword> / >
< asp:HyperLinkField DataNavigateUrlFields = product_id DataNavigateUrlFormatSt ring = 〜/ ProductDetailes.aspx?product_id = {0} DataTextField = product_id DataTextFormatString = 点击查看产品详细信息.. / >
< /字段 >

< FooterStyle BackColor = Tan / >
< HeaderStyle BackColor = Tan 字体粗体 = True / >
< PagerStyle BackColor = PaleGoldenrod ForeColor = DarkSlateBlue Horizo​​ntalAlign = 中心 / < span class =code-keyword>>

< / asp:DetailsView >

< br / >
< / ContentTemplate > ;

< / asp:UpdatePanel >





但是当我点击删除它不起作用,它需要一个触发但我不知道它..



任何帮助请插入,更新,删除触发器将不胜感激

解决方案

< pre lang =xml> < asp:SqlDataSource ID = SqlDataSource1 runat = server ConnectionString = <%


ConnectionStrings:ConnectionString %>

UpdateCommand = 更新产品SET name = @ name,category = @ category WHERE product_id = @ product_id

InsertCommand = INSERT INTO产品(name,category,product_id)VALUES(@ name,@ category,@ product_id)

DeleteCommand = DELETE FROM [Products] WHERE product_id = @ product_id; SelectCommand = SELECT * FROM [Products] >
< InsertParameters >
< asp:参数 名称 = 名称 / >
< asp:参数 名称 = 类别 / >
< asp:参数 名称 = product_id / >
< / InsertParameters > ;
< / asp:SqlDataSource >


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

解决方案

<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>


这篇关于UpdatePanel中DetailesView的Insert,Update,Delete触发器是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆