今天终于发薪了.苦等了十几天啊.顺便请教问题(ASP.NET)

chunfeng007 2006-10-24 03:57:24
今天终于发薪了.苦等了两周啊.还当不发了呢.再不发打算明天不来上班了.结果发了,哈哈.
我原来学ASP的,现在在学.NET
刚学.现在遇到一个问题,请各位高手指教.
public partial class edit : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int id = Convert.ToInt32(Request.QueryString["id"]);
idid.Text = Request.QueryString["id"];
BindTopicData(id);
}
private void BindTopicData(int id)
{ ///获取数据

OleDbConnection con = new OleDbConnection(getconn());

con.Open();
OleDbCommand cmd = new OleDbCommand("select * from ZD_Article where id=" + id, con);
OleDbDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
if (dr.Read())
{

titles.Text = dr["title"].ToString();
writter.Text = dr["writter"].ToString();
Content.Text = dr["Content"].ToString();


con.Close();
}
}
protected string getconn()
{
string connstring;
connstring = ConfigurationManager.ConnectionStrings["dataConnectionString"].ConnectionString;
return connstring;
}
protected void Button1_Click(object sender, EventArgs e)
{
string titless;
titless= titles.Text;
string Contentss ;
Contentss = Content.Text;
Contentss = Server.HtmlEncode(Contentss.Replace("'", "!"));
string writters;
writters= writter.Text;
int idd = Convert.ToInt32(idid.Text);
OleDbConnection con = new OleDbConnection(getconn());
string query;
query = "update ZD_Article set title='" + titless + "',writter='" + writters + "',Content='" + Contentss + "' where id=" + idd;
con.Open();
OleDbCommand cmd = new OleDbCommand(query, con);
if (cmd.ExecuteNonQuery()>0);
{
Response.Write("<script>alert('更新成功!');</script>");
Response.Redirect("Default.aspx");
}
con.Close();
}
}
问题是,我点更新的时候.titles.text,Content.text,writter.text 中的内容不变.
老是修改不了内容,不知道为什么,请高手指点.先谢过了.
...全文
99 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
chunfeng007 2006-10-24
  • 打赏
  • 举报
回复
多谢各位了.
daishengs 2006-10-24
  • 打赏
  • 举报
回复
if(!IsPostBack())
{
int id = Convert.ToInt32(Request.QueryString["id"]);
idid.Text = Request.QueryString["id"];
BindTopicData(id);
}
chunfeng007 2006-10-24
  • 打赏
  • 举报
回复
谢过楼上的.给你二十分.哈哈.
xingyaohua 2006-10-24
  • 打赏
  • 举报
回复
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack())
{
int id = Convert.ToInt32(Request.QueryString["id"]);
idid.Text = Request.QueryString["id"];
BindTopicData(id);
}
}
wj5104 2006-10-24
  • 打赏
  • 举报
回复
請看 IsPostBack

62,133

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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