我创建了这个方法,所以它会更新页面上的标签。我们这里有一堆复选框,指示此人是否有任何限制。当用户登录并看到复选框时,我希望标签显示已选中的复选框,以便用户更轻松地查看此人有哪些限制。
我是 C# 和 ASP.NET 的新手,我想知道,有没有更好/更简单/更有效的方法来解决这个问题?我发现的第一件事是 String.Concat,这就是我在下面的代码中使用它的原因。另外,我似乎无法在后面的代码中使用 line return (a (br /)) (我知道 (br /) 在后面的代码中不起作用)。我尝试了许多不同的方法,但似乎都没有奏效,这就是为什么我在字符串中添加了一个逗号。有什么建议么?
protected void LblLimitsLabel()
{
String strBend = "", strDryDust = "", strStanding = "", strHearing = "", strHeights = "", strHepatitis = "", strLifting = "", strMachines = "", strPulling = "", strPushing = "", strReaching = "", strSeizures = "", strSuddenTemp = "", strVisual = "", strWalking = "", strWheelchair = "", strHelmet = "", strOther = "";
if (chkBend.Checked)
strBend = "Bend/Stoop, ";
if (chkDryDusty.Checked)
strDryDust = "Dry/Dusty, ";
if (chkHearing.Checked)
strHearing = "Hearing, ";
if (chkHeights.Checked)
strHeights = "Heights, ";
if (chkHepatitis.Checked)
strHepatitis = "Hepatitis, ";
if (chkLifting.Checked)
strLifting = "Lifting, ";
if (chkMachines.Checked)
strMachines = "Machines, ";
if (chkPulling.Checked)
strPulling = "Pulling, ";
if (chkPushing.Checked)
strPushing = "Pushing, ";
if (chkReaching.Checked)
strReaching = "Reaching, ";
if (chkSeizures.Checked)
strSeizures = "Seizures, ";
if (chkStanding.Checked)
strStanding = "Standing, ";
if (chkSuddenTemp.Checked)
strSuddenTemp = "Sudden Temp. Changes, ";
if (chkVisual.Checked)
strVisual = "Visual, ";
if (chkWalking.Checked)
strWalking = "Walking, ";
if (chkWheelchair.Checked)
strWheelchair = "Wheelchair, ";
if (chkHelmet.Checked)
strHelmet = "Helmet, ";
strOther = TextBox1.Text;
LblLimits.Text = String.Concat(strBend, strDryDust, strStanding, strHearing, strHeights, strHepatitis, strLifting, strMachines, strPulling, strPushing, strReaching, strSeizures, strSuddenTemp, strVisual, strWalking, strWheelchair, strHelmet, strOther);
}