ページが読み込まれると、データベースにいくつかの値がクエリされ、いくつかのテキスト ボックスに値が入力されます。
protected void Page_Load(object sender, EventArgs e)
{
tadbDataContext tadb = new tadbDataContext();
Dictionary<string, string> hexColors = tadb.msp_silentAuctionColors.ToDictionary(t => t.colorDescription, t => t.colorValue);
tbTextColor.Text = hexColors["textColor"];
tbAltColor.Text = hexColors["altColor"];
tbBackgroundColor.Text = hexColors["backgroundColor"];
}
次に、値を変更し、次のことを行うボタンをクリックして、データベースに再送信しようとします。
using (tadbDataContext tadb = new tadbDataContext())
{
var textColor = tadb.msp_silentAuctionColors.Single(x => x.colorDescription == "textColor");
var altColor = tadb.msp_silentAuctionColors.Single(x => x.colorDescription == "altColor");
var backgroundColor = tadb.msp_silentAuctionColors.Single(x => x.colorDescription == "backgroundColor");
textColor.colorValue = tbTextColor.Text;
altColor.colorValue = tbAltColor.Text;
backgroundColor.colorValue = tbBackgroundColor.Text;
tadb.SubmitChanges();
}
ポストバックされる値は、元の (変更されていない) 値です。ロード時にテキスト ボックスに入力する行をコメント アウトすると、正常に動作します。