在中继器中保存下拉列表值?
我已经在中继器内的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
cmdSave 按钮怎么样,它位于 Repeater 内部,
您需要找出每一行中的 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.
这样做很容易
it is easy to do it like that