我正在更新viewstate表中的行,但它没有更新给我很好的解决方案frds。 [英] I am Updateing row in viewstate table but its not updateing give me good solution 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 need to assign its
Connection
Property to your DatabaseConnectionString
. - 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[^].
You have only declared a SqlCommand
object. Do the following...
这篇关于我正在更新viewstate表中的行,但它没有更新给我很好的解决方案frds。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!