2016-09-14 12 views
0

プログラムを作成しました。その機能の1つは、ドロップダウンリストから項目を選択すると、データベースのデータが自動的にテキストボックスに読み込まれます。私はテキストボックスにデータを埋め込むことができましたが、私が望む方法ではありませんでした。以下は私のコードとdbです。コードの下ドロップダウンリストのインデックスを使用してDBからテキストボックスにデータを自動入力する方法

[http://i.stack.imgur.com/ybOkw.png][1] 

[http://i.stack.imgur.com/jRGu5.png][1] 

[http://i.stack.imgur.com/UJ23n.png][1] 

答えて

0

私がやったことです:

'保護された無効cbPlan1_CheckedChanged(オブジェクト送信者、EventArgsの電子)

{ 
string CoverageBenefit1 = "250,000"; 
string CoverageBenefit2 = "500,000"; 
string CoverageBenefit3 = "3,750,000"; 
string CoverageBenefit4 = "125,000"; 
string CoverageBenefit5 = "625,000"; 
string CoverageBenefit6 = "625,000"; 
string CoverageBenefit7 = "6,250,000"; 
string CoverageBenefit8 = "750,000"; 
string CoverageBenefit9 = "250,000"; 
string CoverageBenefit10 = "1,000,000"; 
string CoverageBenefit11 = "25,000,000"; 
string CoverageBenefit11a = "15,000,000"; 
string CoverageBenefit11b = "25,000,000"; 
string CoverageBenefit12 = "200,000"; 
string CoverageBenefit13 = "0.00"; 
string CoverageBenefit14 = "0.00"; 
if (cbPlan1.Checked) 
{ 
txtCoverageBenefit1.Text = CoverageBenefit1.ToString(); 
txtCoverageBenefit2.Text = CoverageBenefit2.ToString(); 
txtCoverageBenefit3.Text = CoverageBenefit3.ToString(); 
txtCoverageBenefit4.Text = CoverageBenefit4.ToString(); 
txtCoverageBenefit5.Text = CoverageBenefit5.ToString(); 
txtCoverageBenefit6.Text = CoverageBenefit6.ToString(); 
txtCoverageBenefit7.Text = CoverageBenefit7.ToString(); 
txtCoverageBenefit8.Text = CoverageBenefit8.ToString(); 
txtCoverageBenefit9.Text = CoverageBenefit9.ToString(); 
txtCoverageBenefit10.Text = CoverageBenefit10.ToString(); 
txtCoverageBenefit11.Text = CoverageBenefit11.ToString(); 
txtCoverageBenefit11a.Text = CoverageBenefit11a.ToString(); 
txtCoverageBenefit11b.Text = CoverageBenefit11b.ToString(); 
txtCoverageBenefit12.Text = CoverageBenefit12.ToString(); 
txtCoverageBenefit13.Text = CoverageBenefit13.ToString(); 
txtCoverageBenefit14.Text = CoverageBenefit14.ToString(); 
} 
else 
{ 
txtCoverageBenefit1.Text = ""; 
txtCoverageBenefit2.Text = ""; 
txtCoverageBenefit3.Text = ""; 
txtCoverageBenefit4.Text = ""; 
txtCoverageBenefit5.Text = ""; 
txtCoverageBenefit6.Text = ""; 
txtCoverageBenefit7.Text = ""; 
txtCoverageBenefit8.Text = ""; 
txtCoverageBenefit9.Text = ""; 
txtCoverageBenefit10.Text = ""; 
txtCoverageBenefit11.Text = ""; 
txtCoverageBenefit11a.Text = ""; 
txtCoverageBenefit11b.Text = ""; 
txtCoverageBenefit12.Text = ""; 
txtCoverageBenefit13.Text = ""; 
txtCoverageBenefit14.Text = ""; 
} 
} 
protected void cbPlan2_CheckedChanged(object sender, EventArgs e) 
{ 
string CoverageBenefit1 = "375000"; 
string CoverageBenefit2 = "750000"; 
string CoverageBenefit3 = "5000000"; 
string CoverageBenefit4 = "175000"; 
string CoverageBenefit5 = "625000"; 
string CoverageBenefit6 = "625000"; 
string CoverageBenefit7 = "8750000"; 
string CoverageBenefit8 = "1000000"; 
string CoverageBenefit9 = "250000"; 
string CoverageBenefit10 = "1250000"; 
string CoverageBenefit11 = "50000000"; 
string CoverageBenefit11a = "30000000"; 
string CoverageBenefit11b = "50000000"; 
string CoverageBenefit12 = "250000"; 
string CoverageBenefit13 = "125000"; 
string CoverageBenefit14 = "50000"; 
if (cbPlan2.Checked) 
{ 
txtCoverageBenefit1.Text = CoverageBenefit1.ToString(); 
txtCoverageBenefit2.Text = CoverageBenefit2.ToString(); 
txtCoverageBenefit3.Text = CoverageBenefit3.ToString(); 
txtCoverageBenefit4.Text = CoverageBenefit4.ToString(); 
txtCoverageBenefit5.Text = CoverageBenefit5.ToString(); 
txtCoverageBenefit6.Text = CoverageBenefit6.ToString(); 
txtCoverageBenefit7.Text = CoverageBenefit7.ToString(); 
txtCoverageBenefit8.Text = CoverageBenefit8.ToString(); 
txtCoverageBenefit9.Text = CoverageBenefit9.ToString(); 
txtCoverageBenefit10.Text = CoverageBenefit10.ToString(); 
txtCoverageBenefit11.Text = CoverageBenefit11.ToString(); 
txtCoverageBenefit11a.Text = CoverageBenefit11a.ToString(); 
txtCoverageBenefit11b.Text = CoverageBenefit11b.ToString(); 
txtCoverageBenefit12.Text = CoverageBenefit12.ToString(); 
txtCoverageBenefit13.Text = CoverageBenefit13.ToString(); 
txtCoverageBenefit14.Text = CoverageBenefit14.ToString(); 
} 
else 
{ 
txtCoverageBenefit1.Text = ""; 
txtCoverageBenefit2.Text = ""; 
txtCoverageBenefit3.Text = ""; 
txtCoverageBenefit4.Text = ""; 
txtCoverageBenefit5.Text = ""; 
txtCoverageBenefit6.Text = ""; 
txtCoverageBenefit7.Text = ""; 
txtCoverageBenefit8.Text = ""; 
txtCoverageBenefit9.Text = ""; 
txtCoverageBenefit10.Text = ""; 
txtCoverageBenefit11.Text = ""; 
txtCoverageBenefit11a.Text = ""; 
txtCoverageBenefit11b.Text = ""; 
txtCoverageBenefit12.Text = ""; 
txtCoverageBenefit13.Text = ""; 
txtCoverageBenefit14.Text = ""; 

} }'

と同様にプランそれは非常に面倒ですが、これは私の目的を達成するのに役立ちます。誰も私がこれを簡単にするのを助けることができますか?

関連する問題