<asp:DropDownList ID="DDLStatusChange" runat="server" AppendDataBoundItems="true">
<asp:ListItem>-Select-</asp:ListItem>
<asp:ListItem>Just Received</asp:ListItem>
<asp:ListItem>Post Approval</asp:ListItem>
</asp:DropDownList>
<asp:TextBox ID="txtStatusChange" runat="server" Width="200"></asp:TextBox>
<asp:Button ID="btnStatuschange"
runat="server" Text="Status Change" onclick="btnStatuschange_Click" />
コード ビハインド C#
protected void btnStatuschange_Click(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["OptimaWebCustomerQueryCon"].ConnectionString))
{
conn.Open();
string str = @"Update TblMasterinfo SET AppLoanStatus=@AppLoanStatus Where appid in (@Statuschange)";
using (SqlCommand com = new SqlCommand(str, conn))
{
com.Parameters.AddWithValue("@Statuschange", Convert.ToInt32(txtStatusChange.Text));
com.Parameters.AddWithValue("@AppLoanStatus",DDLStatusChange.SelectedValue);
com.ExecuteNonQuery();
}
conn.Close();
}
}
問題:
txtStatusChange にこれらの更新レコードの appid を入力します。複数の記録を更新するとエラーが発生する
例外の詳細: System.FormatException: Input string was not in a correct format.