我正在更新viewstate表中的行,但它没有更新给我很好的解决方案frds。 [英] I am Updateing row in viewstate table but its not updateing give me good solution frds.

查看:52
本文介绍了我正在更新viewstate表中的行,但它没有更新给我很好的解决方案frds。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

protected void GridView3_RowUpdating(object sender,GridViewUpdateEventArgs e)

{



GridViewRow row =(GridViewRow)GridView3.Rows [e。 RowIndex];

DataTable tableupd = ViewState [CurrentTable] as DataTable;

SqlCommand cmd = new SqlCommand(更新tableupd set AssignedPriority = @ AssignedPriority,其中JobCode = @ JobCode );

GridView3.DataSource = tableupd;

GridView3.DataBind();



}

protected void GridView3_RowUpdating(object sender, GridViewUpdateEventArgs e)
{

GridViewRow row = (GridViewRow)GridView3.Rows[e.RowIndex];
DataTable tableupd = ViewState["CurrentTable"] as DataTable;
SqlCommand cmd = new SqlCommand("Update tableupd set AssignedPriority=@AssignedPriority where JobCode=@JobCode");
GridView3.DataSource = tableupd;
GridView3.DataBind();

}

推荐答案

SqlCommand cmd = new SqlCommand("Update tableupd set AssignedPriority=@AssignedPriority where JobCode=@JobCode");



您只声明了一个 SqlCommand 对象。执行以下操作...

  • 您需要将 Connection 属性分配给您的数据库 ConnectionString
  • 然后定义您在命令查询中使用的参数 @AssignedPriority @JobCode
  • 打开 SqlConnection
  • 最后,执行命令使用 SqlCommand.ExecuteNonQuery Method [ ^ ]。

  • You have only declared a SqlCommand object. Do the following...

    • You need to assign its Connection Property to your Database ConnectionString.
    • Then define the parameters you have used in the Command Query that are "@AssignedPriority" and "@JobCode".
    • Open the SqlConnection.
    • At last, Execute the Command using SqlCommand.ExecuteNonQuery Method[^].

    • 这篇关于我正在更新viewstate表中的行,但它没有更新给我很好的解决方案frds。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆