菜鸟求教高手!急用(新闻发布系统,增删添加页面问题)

meifeisewuru 2009-12-27 01:28:12
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="newsAdminDetail.aspx.cs" Inherits="newsInsert" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>新闻增加</title>
<link href="Style.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript">
// <!CDATA[

function P1_onclick() {

}

// ]]>
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<p id="P1" class="style4" onclick="return P1_onclick()" style="left: -21px; behavior: url(newsAdmin.aspx);
vertical-align: bottom; width: 95%; position: absolute; top: 19px; text-align: right">
<img align="left" class="style3" src="image/newsCenter_r2_c1.jpg" />
<a class="nav" href="news.aspx"><span style="font-size: 10pt; color: #006699">回到主页</span></a>
   <asp:LoginStatus ID="LoginStatus2" runat="server" Height="4px" LogoutAction="Redirect"
LogoutPageUrl="~/news.aspx" Width="32px" />
  </p>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<asp:LoginView ID="LoginView1" runat="server">
<LoggedInTemplate>
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" BorderWidth="0px"
Caption="新闻数据管理" CellPadding="4" CellSpacing="1" CssClass="Forumline" DataKeyNames="news_id"
DataSourceID="SqlDataSource1" DefaultMode="Edit" Height="50px" Width="95%">
<RowStyle CssClass="row1" HorizontalAlign="Left" />
<FieldHeaderStyle CssClass="row3" Font-Bold="True" HorizontalAlign="Center" Width="80px" />
<Fields>
<asp:TemplateField HeaderText="类别">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" SelectedValue='<%# Bind("news_type") %>'>
<asp:ListItem>政治</asp:ListItem>
<asp:ListItem>经济</asp:ListItem>
<asp:ListItem>文体</asp:ListItem>
<asp:ListItem>生活</asp:ListItem>
<asp:ListItem>其他</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<InsertItemTemplate>
<asp:DropDownList ID="DropDownList2" runat="server" SelectedValue='<%# Bind("news_type") %>'>
<asp:ListItem>政治</asp:ListItem>
<asp:ListItem>经济</asp:ListItem>
<asp:ListItem>文体</asp:ListItem>
<asp:ListItem>生活</asp:ListItem>
<asp:ListItem>其他</asp:ListItem>
</asp:DropDownList>
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="日期">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Now() %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("news_date") %>'></asp:Label>
</InsertItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="news_subject" HeaderText="标题" SortExpression="news_subject" />
<asp:BoundField DataField="news_editor" HeaderText="编辑者" SortExpression="news_editor" />
<asp:TemplateField HeaderText="内容">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Height="100px" Text='<%# Bind("news_content") %>'
TextMode="MultiLine" Width="450px"></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Height="100px" Text='<%# Bind("news_content") %>'
TextMode="MultiLine" Width="450px"></asp:TextBox>
</InsertItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" ShowInsertButton="True" />
</Fields>
<AlternatingRowStyle CssClass="row2" />
</asp:DetailsView>
</LoggedInTemplate>
<AnonymousTemplate>
<img src="image/shou.jpg" />请先执行<asp:LoginStatus ID="LoginStatus1" runat="server"
LogoutPageUrl="~/newsInsert.aspx" />
操作  
</AnonymousTemplate>
</asp:LoginView>
<br />
<br />
<br />
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
DeleteCommand="DELETE FROM [news] WHERE [news_id] = @news_id" InsertCommand="INSERT INTO [news] ([news_id], [news_type], [news_date], [news_subject], [news_content], [news_editor]) VALUES (@news_id, @news_type, @news_date, @news_subject, @news_content, @news_editor)"
SelectCommand="SELECT * FROM [news]"
UpdateCommand="UPDATE [news] SET [news_type] = @news_type, [news_date] = @news_date, [news_subject] = @news_subject, [news_content] = @news_content, [news_editor] = @news_editor WHERE [news_id] = @news_id">
<DeleteParameters>
<asp:Parameter Name="news_id" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="news_type" Type="String" />
<asp:Parameter DbType="Date" Name="news_date" />
<asp:Parameter Name="news_subject" Type="String" />
<asp:Parameter Name="news_content" Type="String" />
<asp:Parameter Name="news_editor" Type="String" />
<asp:Parameter Name="news_id" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="news_id" Type="Int32" />
<asp:Parameter Name="news_type" Type="String" />
<asp:Parameter DbType="Date" Name="news_date" />
<asp:Parameter Name="news_subject" Type="String" />
<asp:Parameter Name="news_content" Type="String" />
<asp:Parameter Name="news_editor" Type="String" />
</InsertParameters>
</asp:SqlDataSource>

</div>
</form>
</body>
</html>
========================================================================================
新闻发布系统的修改、添加、删除页面。。
请大侠赐教。。按添加之后,还是出现更新的页面。。
还有更新出现SQL不支持date数据。。。

其中有错误说。。 <asp:TextBox ID="TextBox1" runat="server" Text='<%# Now() %>'></asp:TextBox>
这个Now是不是有问题。。他说上下文中不存在名称。。不过,书上是这么写的。。

菜鸟求大侠指教!!
...全文
70 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
lijing3333 2009-12-27
  • 打赏
  • 举报
回复
在pageload里面写
TextBox1.text = DateTime.Now.ToString();

或者写个方法 前台调用
public string Now()
{
return DateTime.Now.ToString();
}
//前台

<asp:TextBox ID="TextBox1" runat="server" Text=' <%= Now() %>'> </asp:TextBox>
silentwins 2009-12-27
  • 打赏
  • 举报
回复
protected string Now()
{
return DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
meifeisewuru 2009-12-27
  • 打赏
  • 举报
回复
那应该怎么写。。请帮忙写一个。。
老师的作业,马上要交了。。帮忙写一个,谢谢啦。。类似的!
wuyq11 2009-12-27
  • 打赏
  • 举报
回复
Now函数是否存在
很少这样写
silentwins 2009-12-27
  • 打赏
  • 举报
回复
你这个Now在哪里?

cs页面中应该存在一个最少为protected的Now()函数

protected string Now()
{
return "content that you want to be displayed!";
}

110,567

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧