C# 取决于结束日期的动态下拉列表
我有一个下拉列表,指示应用程序当前或已过期的状态。我希望在结束日期超过当前日期后将此值更改为过期 在c 下面是加载状态的代码C# 取决于结束日期的动态下拉列表,c#,C#,我有一个下拉列表,指示应用程序当前或已过期的状态。我希望在结束日期超过当前日期后将此值更改为过期 在c 下面是加载状态的代码 public void loadStatus() { ArrayList arrNew = new ArrayList(); String[] tmpArray = InfoLoader.loadStatus(2).Split('\n'); for (int i = 0; i < tmpArray.Length; i++) {
public void loadStatus()
{
ArrayList arrNew = new ArrayList();
String[] tmpArray = InfoLoader.loadStatus(2).Split('\n');
for (int i = 0; i < tmpArray.Length; i++)
{
String[] cols = tmpArray[i].Split('\t');
if (cols.Length == 2)
{
arrNew.Add(new ListValues(cols[0], cols[1], ListValues.FORWARD));
}
}
cmboStatus.DataSource = arrNew;
cmboStatus.DisplayMember = "Desc";
cmboStatus.ValueMember = "ID";
}
请帮我做这个。我想知道如何在上述代码中插入if条件。您有这一行:
cmboStatus.SelectedValue = row["EmpAppointStatusID"].ToString().Trim();
所以你可以这样做:
if (some interesting condition here)
{
cmboStatus.SelectedValue = "fab new value";
}
else
{
cmboStatus.SelectedValue = row["EmpAppointStatusID"].ToString().Trim();
}
if (some interesting condition here)
{
cmboStatus.SelectedValue = "fab new value";
updateStatus(parameters needed)
}
else
... more stuff
然而,从你的问题中不清楚它是否会——但我预计这会导致一个问题:
因为这不会将fab新值保存到数据库中,所以可能会导致问题。所以我建议如下:
if (some interesting condition here)
{
cmboStatus.SelectedValue = "fab new value";
}
else
{
cmboStatus.SelectedValue = row["EmpAppointStatusID"].ToString().Trim();
}
if (some interesting condition here)
{
cmboStatus.SelectedValue = "fab new value";
updateStatus(parameters needed)
}
else
... more stuff