我是菜鸟一个,可能很简单,别笑我啊!
在使用gridview控件时,启用了"启用删除",数据源里面也生成了删除啊,为什么点击"删除"后一点作用都不起呢???
代码如下:
---------------------------------------------
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White"
BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataSourceID="SqlDataSource1"
GridLines="Horizontal" Width="600px">
<FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
<Columns>
<asp:BoundField DataField="Title" HeaderText="包含的栏目" SortExpression="Title">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:TemplateField HeaderText="修改">
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<a href='edit.aspx?source=AboutUs&id=<%# Eval("USID") %>' class="lj1"><asp:Label ID="lblEdit" runat="server" Text='<%# db.book(Eval("USID").ToString()) %>'></asp:Label></a>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="预览">
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<a href='PreView.aspx?source=AboutUs&id=<%# Eval("USID") %>' class="lj1"><asp:Label ID="lblPreview" runat="server" Text="预览" Enabled='<%# IsShow.showUs(Eval("USID").ToString()) %>'></asp:Label></a>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="DateTime" HeaderText="最后修改的时间" SortExpression="DateTime">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:CommandField HeaderText="删除" ShowDeleteButton="True" ShowHeader="True">
<ItemStyle HorizontalAlign="Center" />
</asp:CommandField>
</Columns>
<RowStyle BackColor="#E7E7FF" ForeColor="Black" Height="25px" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
<HeaderStyle Font-Bold="True" ForeColor="#F7F7F7" CssClass="head1" />
<AlternatingRowStyle BackColor="#F7F7F7" ForeColor="Black" Height="25px" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:kunxiang %>"
SelectCommand="SELECT [USID], [Title], [DateTime] FROM [AboutUs] ORDER BY [DateTime] DESC" DeleteCommand="DELETE FROM [AboutUs] WHERE [USID] = @USID" InsertCommand="INSERT INTO [AboutUs] ([Title], [DateTime]) VALUES (@Title, @DateTime)" UpdateCommand="UPDATE [AboutUs] SET [Title] = @Title, [DateTime] = @DateTime WHERE [USID] = @USID">
<DeleteParameters>
<asp:Parameter Name="USID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="DateTime" Type="DateTime" />
<asp:Parameter Name="USID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="DateTime" Type="DateTime" />
</InsertParameters>
</asp:SqlDataSource>-------------------------
好象之前有一次成功过,不知道为什么多数时候不行;还有如果自己建了Template列,拖如个linkbutton,将其commandname设为delete,好象也可以啊
拜托
顺便祝大家五一快乐!!!!!!!!!!!
在使用gridview控件时,启用了"启用删除",数据源里面也生成了删除啊,为什么点击"删除"后一点作用都不起呢???
代码如下:
---------------------------------------------
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White"
BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataSourceID="SqlDataSource1"
GridLines="Horizontal" Width="600px">
<FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
<Columns>
<asp:BoundField DataField="Title" HeaderText="包含的栏目" SortExpression="Title">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:TemplateField HeaderText="修改">
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<a href='edit.aspx?source=AboutUs&id=<%# Eval("USID") %>' class="lj1"><asp:Label ID="lblEdit" runat="server" Text='<%# db.book(Eval("USID").ToString()) %>'></asp:Label></a>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="预览">
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<a href='PreView.aspx?source=AboutUs&id=<%# Eval("USID") %>' class="lj1"><asp:Label ID="lblPreview" runat="server" Text="预览" Enabled='<%# IsShow.showUs(Eval("USID").ToString()) %>'></asp:Label></a>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="DateTime" HeaderText="最后修改的时间" SortExpression="DateTime">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:CommandField HeaderText="删除" ShowDeleteButton="True" ShowHeader="True">
<ItemStyle HorizontalAlign="Center" />
</asp:CommandField>
</Columns>
<RowStyle BackColor="#E7E7FF" ForeColor="Black" Height="25px" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
<HeaderStyle Font-Bold="True" ForeColor="#F7F7F7" CssClass="head1" />
<AlternatingRowStyle BackColor="#F7F7F7" ForeColor="Black" Height="25px" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:kunxiang %>"
SelectCommand="SELECT [USID], [Title], [DateTime] FROM [AboutUs] ORDER BY [DateTime] DESC" DeleteCommand="DELETE FROM [AboutUs] WHERE [USID] = @USID" InsertCommand="INSERT INTO [AboutUs] ([Title], [DateTime]) VALUES (@Title, @DateTime)" UpdateCommand="UPDATE [AboutUs] SET [Title] = @Title, [DateTime] = @DateTime WHERE [USID] = @USID">
<DeleteParameters>
<asp:Parameter Name="USID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="DateTime" Type="DateTime" />
<asp:Parameter Name="USID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="DateTime" Type="DateTime" />
</InsertParameters>
</asp:SqlDataSource>-------------------------
好象之前有一次成功过,不知道为什么多数时候不行;还有如果自己建了Template列,拖如个linkbutton,将其commandname设为delete,好象也可以啊
拜托
顺便祝大家五一快乐!!!!!!!!!!!
-----------
可是asp:CommandField里没有这个属性啊????
<asp:CommandField DeleteText="删除" ShowDeleteButton="true"
-----------
撞邪了,还是不行
是不是应该把"Eval"改成"Bind"啊?
可是我改成Bind后,却报错?
为什么?
真的这么复杂?
还是快放假了,我心已不在工作上了?