我创建了一个程序,其中一个功能是当您从下拉列表中选择一个项目时,数据库中的数据将自动填充到文本框中。我能够填充文本框中的数据,但不是我想要的方式。下面是我的代码和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 :(得分:0)
以下代码就是我所做的:
' protected void cbPlan1_CheckedChanged(object sender,EventArgs e)
{
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 = "";
} }'
以及计划3到5.这有助于我实现我的目标,虽然这是非常乏味的。任何人都可以帮我解决这个问题吗?