【问题标题】:Dropdownlist in repeater control中继器控件中的下拉列表
【发布时间】:2012-02-11 19:08:53
【问题描述】:

我有 3 个下拉列表,其中包含数据库中的一组值。在我的页面中,我有不同的控件。我打算在转发器控件中添加这个下拉列表。

当用户选择一个值时,该值将通过控件内的保存按钮或自动保存到数据库中。

如果可以,请告诉我吗?如果是,任何可以共享的代码都会有所帮助。

【问题讨论】:

    标签: asp.net drop-down-menu repeater


    【解决方案1】:

    是的,这是可能的。诀窍是下拉列表的数据源与中继器的数据源是分开的。

    【讨论】:

    • 我用谷歌搜索了你的标题,第一次点击有示例代码:devasp.net/net/articles/display/265.html
    • 谢谢史蒂夫。这不是我想要的。我想要一个中继器控件内的下拉列表。
    【解决方案2】:

    示例代码如下:

    protected void cmdSave_Click(object sender, EventArgs e)
    {
     foreach (RepeaterItem ri in GeneralRepeater.Items)
            {
                switch (ri.ItemType)
                {
                    case ListItemType.Item:
                    case ListItemType.AlternatingItem:
    
                        DropDownList GetValue = (DropDownList)ri.FindControl("GeneralDDL");
                        var sSelectedValue = GetValue.SelectedValue;
    
                        for (int index = 0; index <= PocDiagnoses.MAX_DIAGNOSIS; index++)
                        {
                            foreach (RepeaterItem ri1 in GeneralRepeater.Items)
                            {
                                int iItemIndex = ri1.ItemIndex;
                                DropDownList myDDL = (DropDownList)GeneralRepeater.Items[index].FindControl("GeneralDDL");
    
                                FirstPlanOfCare.Diagnoses.Diagnoses[index] = new PatientDiagnosis(myDDL.SelectedValue, new SynergyOnSetDate(new System.DateTime(Year, Month, Day)), "01/02/2011"); //Insert Diagnosis Value
    
                            }
                        }
                        break;
                }
            }
            //Create
            Chart.AddPlanOfCare(FirstPlanOfCare);
    

    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-07
      • 2014-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多