在NewsList.aspx页面中的GridView里,我配置这样一个列,用来导航到另一个新闻编辑页面,<asp:HyperLinkField DataNavigateUrlFields="id" DataNavigateUrlFormatString="NewsEdit.aspx?action=edit&id={0}"
Text="编辑文章" />
在另一个页面NewsEdit.aspx页面中有一个FormView,编辑模版代码如下:
<asp:FormView ID="FormViewNews" runat="server" DataKeyNames="id" DataSourceID="AccessDataSource1" DefaultMode="Edit" OnItemInserted="FormViewNews_ItemInserted">
<EditItemTemplate>
<ul>
<li>文章标题:</li>
<li>
<asp:TextBox ID="TextBoxTitle" runat="server" Text='<%# Bind("title") %>' CssClass="longTextBox">
</asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="请输入标题"
ControlToValidate="TextBoxTitle" Text="*"></asp:RequiredFieldValidator>
</li>
<li>文章副标题:</li>
<li>
<asp:TextBox ID="TextBoxSubTitle" runat="server" Text='<%# Bind("subtitle") %>' CssClass="longTextBox">
</asp:TextBox></li>
<li>所属栏目:</li>
<li>
<asp:DropDownList ID="DropDownListChildColumn" runat="server" DataSourceID="AccessDataSource2" DataTextField="ChildColumn" DataValueField="ChildColumn"
SelectedValue='<%#Bind("childColumn") %>'>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="RequiredFieldValidator"
ControlToValidate="DropDownListChildColumn" Text="*"></asp:RequiredFieldValidator>
</li>
<li>所属专题:</li>
<li>
<asp:DropDownList ID="DropDownListCaption" runat="server" DataSourceID="AccessDataSource3" DataTextField="namee" DataValueField="namee"
SelectedValue='<%#Bind("caption") %>'>
</asp:DropDownList>
</li>
<li>链接外部URL:</li>
<li>
<asp:TextBox ID="outerUrlTextBox" runat="server" Text='<%# Bind("url") %>' CssClass="longTextBox">
</asp:TextBox>
</li>
<li>
是否为焦点新闻:<asp:CheckBox ID="CheckBoxIsFocus" runat="server" Checked='<%#Bind("hot") %>' />
</li>
<li>文章内容:</li>
<li>
<ftb:FreeTextBox ID="FreeTextBox1" runat="server" Width="700" ButtonPath="images/ftb/office2003/" Text='<%#Bind("content") %>' />
</li>
<li>发表时间:
<asp:TextBox ID="releasedTimeTextBox" runat="server" Text='<%# Bind("datee") %>' CssClass="leftLi">
</asp:TextBox>作者:<asp:TextBox ID="TextBoxAuthor" runat="server" Text='<%# Bind("author") %>'>
</asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ErrorMessage="文章作者不能为空"
ControlToValidate="TextBoxAuthor" Text="*"></asp:RequiredFieldValidator>
</li>
<li> 编辑人员:<asp:TextBox ID="TextBoxEditor" runat="server" Text='<%# Bind("editor") %>' CssClass="leftLi">
</asp:TextBox>来源:<asp:TextBox ID="fromWhereTextBox" runat="server" Text='<%# Bind("fro") %>'>
</asp:TextBox>
</li>
<li>
auditing:
<asp:TextBox ID="auditingTextBox" runat="server" Text='<%# Bind("auditing") %>'>
</asp:TextBox>
</li>
<li>
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" CssClass="submitButton"
Text="更新">
</asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" CssClass="cancelButton"
Text="取消">
</asp:LinkButton>
</li>
</ul>
</EditItemTemplate>
数据源的代码如下:
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/cjxxxred.mdb"
DeleteCommand="DELETE FROM [News] WHERE [id] = ?"
InsertCommand="INSERT INTO [News] ([childColumn], [title], [subtitle], [content], [datee], [auditing], [hot], [author], [fro], [editor], [caption], [url]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
SelectCommand="SELECT [childColumn], [title], [subtitle], [content], [datee], [auditing], [hot], [author], [fro], [editor], [caption], [url] FROM [News] WHERE [id]=?"
UpdateCommand="UPDATE [News] SET [childColumn] = ?, [title] = ?, [subtitle] = ?, [content] = ?, [datee] = ?, [auditing] = ?, [hot] = ?, [author] = ?, [fro] = ?, [editor] = ?, [caption] = ?, [url] = ? WHERE [id] = ?">
<SelectParameters>
<asp:QueryStringParameter Name="id" Type="int32" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="id" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="childColumn" Type="String" />
<asp:Parameter Name="title" Type="String" />
<asp:Parameter Name="subtitle" Type="String" />
<asp:Parameter Name="content" Type="String" />
<asp:Parameter Name="datee" Type="DateTime" />
<asp:Parameter Name="auditing" Type="String" />
<asp:Parameter Name="hot" Type="String" />
<asp:Parameter Name="author" Type="String" />
<asp:Parameter Name="fro" Type="String" />
<asp:Parameter Name="editor" Type="String" />
<asp:Parameter Name="caption" Type="String" />
<asp:Parameter Name="url" Type="String" />
<asp:Parameter Name="id" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="childColumn" Type="String" />
<asp:Parameter Name="title" Type="String" />
<asp:Parameter Name="subtitle" Type="String" />
<asp:Parameter Name="content" Type="String" />
<asp:Parameter Name="datee" Type="DateTime" />
<asp:Parameter Name="auditing" Type="String" />
<asp:Parameter Name="hot" Type="String" />
<asp:Parameter Name="author" Type="String" />
<asp:Parameter Name="fro" Type="String" />
<asp:Parameter Name="editor" Type="String" />
<asp:Parameter Name="caption" Type="String" />
<asp:Parameter Name="url" Type="String" />
</InsertParameters>
</asp:AccessDataSource>
当我点击GridView中的编辑文章的时候,导航到了NewsEdit.aspx页面,但是编辑模版的内容不出现了,里面什么也没有,我不知道是什么原因?还有就是FormView中的编辑模版中的数据怎么得到的,是不是调用了数据源的Select方法?
谢谢各位解答!