ASP.NET和SQL Server2005中,如何将留言人和留言主题自动添加到回复界面里?
就是在留言那点击自动回复,然后页面跳转到回复界面,但是此时要把留言人和留言时间自动添加过去,管理只需要写回复内容即可了。。。。...
就是在留言那点击自动回复,然后页面跳转到回复界面,但是此时要把留言人和留言时间自动添加过去,管理只需要写回复内容即可了。。。。
展开
2个回答
展开全部
/// <summary>
/// 绑定数据的方法
/// </summary>
private void Bind() {
//绑定数据到gridview
DataSet ds = DBhelp.executedataset("select * from users");
GridView1.DataSource = ds;
GridView1.DataBind(); //绑定数据到detailview
DetailsView1.DataSource = ds;
DetailsView1.DataBind();
}
/// <summary>
/// 修改保存
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void DetailsView1_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
{
//获取要修改的数据
string loginid = (DetailsView1.Rows[DetailsView1.PageIndex].FindControl("lblloginid") as Label).Text;
string loginpwd = (DetailsView1.Rows[DetailsView1.PageIndex].FindControl("txtloginpwd") as TextBox).Text;
string name = (DetailsView1.Rows[DetailsView1.PageIndex].FindControl("txtname") as TextBox).Text;
int sex = (DetailsView1.Rows[DetailsView1.PageIndex].FindControl("chbsex") as CheckBox).Checked ? 1 : 0;
string face = (DetailsView1.Rows[DetailsView1.PageIndex].FindControl("txtface") as TextBox).Text;
string reamark = (DetailsView1.Rows[DetailsView1.PageIndex].FindControl("txtreamark") as TextBox).Text; //非空判断
//保存更新
string sql = string.Format("update users set loginpwd='{0}',name='{1}',sex={2},face='{3}',reamark='{4}' where loginid='{5}'", loginpwd, name, sex, face, reamark, loginid); int result = DBhelp.executeupdateinsertdelte(sql);
if (result > 0)
{
Page.ClientScript.RegisterStartupScript(GetType(),"","<script>alert('保存成功');</script>"); //切换状态
DetailsView1.ChangeMode(DetailsViewMode.ReadOnly); //重新绑定数据
Bind();
}
else
{
Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('保存失败');</script>"); }
}
/// 绑定数据的方法
/// </summary>
private void Bind() {
//绑定数据到gridview
DataSet ds = DBhelp.executedataset("select * from users");
GridView1.DataSource = ds;
GridView1.DataBind(); //绑定数据到detailview
DetailsView1.DataSource = ds;
DetailsView1.DataBind();
}
/// <summary>
/// 修改保存
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void DetailsView1_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
{
//获取要修改的数据
string loginid = (DetailsView1.Rows[DetailsView1.PageIndex].FindControl("lblloginid") as Label).Text;
string loginpwd = (DetailsView1.Rows[DetailsView1.PageIndex].FindControl("txtloginpwd") as TextBox).Text;
string name = (DetailsView1.Rows[DetailsView1.PageIndex].FindControl("txtname") as TextBox).Text;
int sex = (DetailsView1.Rows[DetailsView1.PageIndex].FindControl("chbsex") as CheckBox).Checked ? 1 : 0;
string face = (DetailsView1.Rows[DetailsView1.PageIndex].FindControl("txtface") as TextBox).Text;
string reamark = (DetailsView1.Rows[DetailsView1.PageIndex].FindControl("txtreamark") as TextBox).Text; //非空判断
//保存更新
string sql = string.Format("update users set loginpwd='{0}',name='{1}',sex={2},face='{3}',reamark='{4}' where loginid='{5}'", loginpwd, name, sex, face, reamark, loginid); int result = DBhelp.executeupdateinsertdelte(sql);
if (result > 0)
{
Page.ClientScript.RegisterStartupScript(GetType(),"","<script>alert('保存成功');</script>"); //切换状态
DetailsView1.ChangeMode(DetailsViewMode.ReadOnly); //重新绑定数据
Bind();
}
else
{
Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('保存失败');</script>"); }
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询