[求助]DetailsView 编辑问题
我在页面里用了一个GridView 来显示公告内容的标题,通过点击一条公告的标题在DetailsView里显示公告的具体内容,并用了DetailsView自带的编辑功能……现在有一个问题是:DetailsView中编辑后的内容不能提交到数据库,还是原来的内容,既无法编辑……请有经验的朋友帮忙看看,谢谢了!
PS: 我是通过数据集访问数据库的……
原代码如下:
1)GridView的代码
asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Id"
DataSourceID="ObjectDataSource1" AllowPaging="True" CellPadding="4" ForeColor="#333333" GridLines="None" PageSize="8">
<Columns>
<asp:TemplateField HeaderText="公告标题" SortExpression="Title">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "~/NoticeManage.aspx?Id="+Eval("Id")%>'><%#Eval("Title") %></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="CreateDate" HeaderText="创建时间" SortExpression="CreateDate" />
<asp:TemplateField HeaderText="操作" >
<ItemTemplate>
<asp:LinkButton runat="server" ID="BtnDelete" CausesValidation="false" CommandName="Delete" Text="删除" OnClientClick="return confirm('确认要删除此行信息吗?')"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="Delete" TypeName="DAONoticeTableAdapters.SP_NoticeSelectAllTableAdapter" >
<DeleteParameters>
<asp:Parameter Name="Id" Type="Int64" />
</DeleteParameters>
</asp:ObjectDataSource>
2)DetailsView的代码
<asp:DetailsView ID="DetailsView2" runat="server" AutoGenerateRows="False" DataSourceID="ObjectDataSource3"
Height="50px" Width="125px" AllowPaging="True">
<Fields>
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="Content" HeaderText="Content" SortExpression="Content" />
<asp:TemplateField ShowHeader="False">
<EditItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
Text="更新"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
Text="取消"></asp:LinkButton>
</EditItemTemplate>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
Text="编辑"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Fields>
</asp:DetailsView>
<asp:ObjectDataSource ID="ObjectDataSource3" runat="server"
SelectMethod="GetNoticeSelectOne" TypeName="DAONoticeTableAdapters.SP_NoticeSelectOneByNoticeIdTableAdapter"
UpdateMethod="UpdateNoticOther" >
<SelectParameters>
<asp:QueryStringParameter Name="NoticeId" QueryStringField="Id" Type="Int64" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="Id" Type="Int64" />
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="Content" Type="String" />
</UpdateParameters>
</asp:ObjectDataSource>
[此贴子已经被作者于2007-8-16 21:46:31编辑过]