更新时间:2023-10-08 17:57:16
1)处理DataBinding
事件
2)下拉列表的Items集合具有FindByValue
,FindByText
方法之类的方法.使用它可以从下拉列表中获取ListItem
.
3)将ListItem''s Selected
属性设置为True
1) Handle theDataBinding
event
2) Dropdown list''s Items collection has methods likeFindByValue
,FindByText
methods. Using that you can get theListItem
from the dropdownlist.
3) Set theListItem''s Selected
property toTrue
Hi,
试试这个
Hi,
try this
<asp:Repeater ID="Rep" runat="server" OnItemDataBound="rep_ItemDataBound">
<ItemTemplate>
<table width="100%">
<tr>
<td valign="top" width="13%" align="left">
<asp:DropDownList ID="Dropdown1" runat="server" Width="80px">
</asp:DropDownList>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
//in the code behind section
in the repDataBound Event find that drop down and bind it
DropDownList myDD = (DropDownList)e.Item.FindControl("Dropdown1");
myDD.DataTextField = "Name";
myDD.DataValueField = "Id";
myDD.DataBind();