我有不同的按钮,像这样
<asp:Button ID="button1" runat="server" Text="single" title="single" EnableViewState="false" />当这个按钮被点击时,我希望列表中的文本发生变化
<asp:BulletedList ID="list1" runat="server" EnableViewState="false">
<asp:ListItem>Item1</asp:ListItem>
<asp:ListItem>Item2</asp:ListItem>
<asp:ListItem>Item3</asp:ListItem>
<asp:ListItem>Item4</asp:ListItem>
</asp:BulletedList>如何在C#中选择列表的第一个、第二个或第三个元素?
protected button_Click(object sender, EventArgs e)
{
list1. ...;
}谢谢。
发布于 2011-01-20 17:13:00
使用ListControl.Items Property。
protected button_Click(object sender, EventArgs e)
{
list1.Items[0] ...;
}发布于 2011-09-01 17:41:59
例如,如果您想要将目录更改为Item1,请使用以下命令:
list1.Items[0].Attributes["class"] = "dir";https://stackoverflow.com/questions/4745218
复制相似问题