开发者

Modify an asp:BulletedList in C#

I've different buttons like this

<asp:Button ID="button1" runat="server" Text="single" title="single" EnableViewState="false" />

When this button is clicked I want that the text in a list like this changes

<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>

How in C# can I select the first, the second or the third element of the list?

protected button开发者_StackOverflow中文版_Click(object sender, EventArgs e)
{
    list1. ...;
}

Thanks.


Use ListControl.Items Property.

protected button_Click(object sender, EventArgs e)
{
    list1.Items[0] ...;
}


For example if you want to change you Item1 to dir, use this :

list1.Items[0].Attributes["class"] = "dir";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜