我对 ASP.NET 技术很陌生,我偶然发现了我的应用程序的特殊问题。每当用户单击 RadGridView 数据行上的按钮时,我都会尝试更新布尔数据库列以将值设置为 True (1)。该按钮似乎工作正常,因为没有错误或异常,但是数据库列根本没有更新。
这是我的代码片段:
ASPX:
<telerik:GridButtonColumn ButtonType="PushButton" ConfirmTextFields="TrxId"
ConfirmTextFormatString="Are you sure you want to release Order No. {0}?"
CommandName="btnRelease" Text="Release Order">
</telerik:GridButtonColumn>
C# :
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == "btnRelease")
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ZEUS"].ConnectionString);
con.Open();
SqlCommand command = new SqlCommand("UPDATE [TransactsData] SET [IsReleased] = 1, [TimeReleased] = GETDATE() WHERE [TrxId] = @TrxId", con);
command.Parameters.AddWithValue("@TrxId", SqlDbType.BigInt);
command.ExecuteNonQuery();
con.Close();
}
}
提前致谢。