在转发器中获取 DropDownList 值
ASPX 页面:
<asp:Repeater ID="GeneralRepeater" runat="server"
OnItemDataBound="GeneralRepeater_OnItemDataBound">
<ItemTemplate>
<tr>
<td>
DxPoc:
<asp:DropDownList ID="GeneralDDL" DataTextField="DiagnosisCode"
DataValueField="DiagnosisCode" runat="server" />
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
代码隐藏:
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();
DataView dv = new DataView(oDiagnosis.GetDiagnosis());
myDDL.DataSource = dv;
myDDL.DataTextField = "DiagnosisCode";
myDDL.DataValueField = "DiagnosisCode";
myDDL.DataBind();
}
}
上面显示的内容无法正常工作。在页面加载期间,没有任何反应 中继器内的下拉列表。
问题:
a.) 如何获取 dropdownlist
的值以及 repeater
内的对象列表?
谢谢!
ASPX PAGE:
<asp:Repeater ID="GeneralRepeater" runat="server"
OnItemDataBound="GeneralRepeater_OnItemDataBound">
<ItemTemplate>
<tr>
<td>
DxPoc:
<asp:DropDownList ID="GeneralDDL" DataTextField="DiagnosisCode"
DataValueField="DiagnosisCode" runat="server" />
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
CODE BEHIND:
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();
DataView dv = new DataView(oDiagnosis.GetDiagnosis());
myDDL.DataSource = dv;
myDDL.DataTextField = "DiagnosisCode";
myDDL.DataValueField = "DiagnosisCode";
myDDL.DataBind();
}
}
The given shown above is not working properly. During page load it nothing happens on the
dropdownlist inside the repeater.
QUESTIONS:
a.) How I'll get the values of my dropdownlist
with list of objects inside the repeater
?
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)