微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

是否在转发器中保存dropdownlist值?

如何解决是否在转发器中保存dropdownlist值?

| 我已经在中继器上的
dropdownlist
上检索了数据库(DescriptionCode)。 现在,我正在尝试将我选择的dropdownlist值保存/添加/插入到我的数据库中,但是我 失败了 非常感谢您提供的任何帮助。谢谢!
 protected void GeneralRepeater_OnItemDataBound(object sender,RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item ||
            e.Item.ItemType == ListItemType.AlternatingItem)
        {
            DropDownList myDDL = (DropDownList)e.Item.FindControl(\"GeneralDDL\");
            Diagnosis oDiagnosis = new Diagnosis();
            PlanOfCare oPlanOfCare = new PlanOfCare();
            DataView dv = new DataView(oDiagnosis.GetDiagnosis());
            myDDL.DataSource = PatientDiagnosis1;
            myDDL.DataTextField = \"DiagnosisCode\";
            myDDL.DataValueField = \"DiagnosisCode\";
            myDDL.DataBind();

            //PUT AN EMPTY FIELD FOR DROPDOWNLIST
            ListItem LI = new ListItem(\"\",\"\");
            myDDL.Items.Insert(0,LI);
            myDDL.SelectedValue = \"0\";



        }
    }


 protected void cmdsave_Click(object sender,EventArgs e)
    {
    oPlanofCareSave.DiagnosesCode = //[1]this must the selected value of dropdownlist inside of repater
    PlanSave(ooPlanofCareSave);
}
    

解决方法

DropDownList myDDL = (DropDownList)GeneralRepeater.Items[indexvalue].FindControl(\"GeneralDDL\");

oPlanofCareSave.DiagnosesCode = myDDL.SelectedValue;
这样很容易做到     ,关于cmdSave按钮,该按钮位于中继器内部 您需要在每一行中找出myDDL,对于每一行,您都需要获取此值。
foreach (RepeaterItem rptItem in RepeaterName.Rows)
{
         DropDownList myDDL = (DropDownList)rptItem.FindControl(\"myDDL\");
}
    

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。