在中继器中保存下拉列表值?

发布于 2024-11-09 12:01:33 字数 1270 浏览 0 评论 0原文

我已经在中继器内的 dropdownlist 上检索了我的数据库(DescriptionCode)。

现在,我尝试在数据库中保存/添加/插入下拉列表的选定值,但

失败了。

非常感谢任何帮助。谢谢!

 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);
}

I already retrieved my database(DescriptionCode) on dropdownlist inside on a repeater.

Now, I'm trying to save/add/insert on my database the selected value of dropdownlist but i

failed.

Any assistance gratefully received. Thanks!

 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);
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

花开浅夏 2024-11-16 12:01:33

cmdSave 按钮怎么样,它位于 Repeater 内部,

您需要找出每一行中的 myDDL,并且对于每一行,您都需要获取该值。

foreach (RepeaterItem rptItem in RepeaterName.Rows)
{
         DropDownList myDDL = (DropDownList)rptItem.FindControl("myDDL");
}

What about the cmdSave button, is that is inside the Repeater

You need to find out myDDL inside each row and for each of them you need to get this value.

foreach (RepeaterItem rptItem in RepeaterName.Rows)
{
         DropDownList myDDL = (DropDownList)rptItem.FindControl("myDDL");
}
终弃我 2024-11-16 12:01:33
DropDownList myDDL = (DropDownList)GeneralRepeater.Items[indexvalue].FindControl("GeneralDDL");

oPlanofCareSave.DiagnosesCode = myDDL.SelectedValue;

这样做很容易

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

oPlanofCareSave.DiagnosesCode = myDDL.SelectedValue;

it is easy to do it like that

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文