web 2.0

ASP.NET(vb.net) & ListBox - asp:ListBox

ASP.NET(vb.net) & ListBox - asp:ListBox - asp:ListBox : Creates a single-selection or multiselection list box.

ShotDev Focus:
- ASP.NET(vb.net) & ListBox - asp:ListBox

ASP.NET(vb.net) & ListBox - asp:ListBox

Tag Control :

<asp:ListBox id="Listbox1"
DataSource="<% databindingexpression %>"
DataTextField="DataSourceField"
DataValueField="DataSourceField"
AutoPostBack="True|False"
Rows="rowcount"
SelectionMode="Single|Multiple"
OnSelectedIndexChanged="OnSelectedIndexChangedMethod"
runat="server">

<asp:ListItem value="value" selected="True|False">
Text
</asp:ListItem>

</asp:ListBox>

Example

ListBox.aspx

<%@ Page Language="VB" %>
<script runat="server">

Sub Button1_Click(sender As Object, e As EventArgs)
Me.lblText1.Text = Me.ListBox1.SelectedItem.Text
End Sub

Sub ListBox2_SelectedIndexChanged(sender As Object, e As EventArgs)
Me.lblText2.Text = Me.ListBox2.SelectedItem.Text
End Sub

</script>
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<form runat="server">
<asp:ListBox id="ListBox1" runat="server">
<asp:ListItem>Item 1</asp:ListItem>
<asp:ListItem>Item 2</asp:ListItem>
<asp:ListItem>Item 3</asp:ListItem>
<asp:ListItem>Item 4</asp:ListItem>
<asp:ListItem>Item 5</asp:ListItem>
</asp:ListBox>
&nbsp;
<asp:ListBox id="ListBox2" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ListBox2_SelectedIndexChanged">
<asp:ListItem>Item 1</asp:ListItem>
<asp:ListItem>Item 2</asp:ListItem>
<asp:ListItem>Item 3</asp:ListItem>
<asp:ListItem>Item 4</asp:ListItem>
<asp:ListItem>Item 5</asp:ListItem>
</asp:ListBox>
<asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Submit"></asp:Button>
<hr />
<asp:Label id="lblText1" runat="server"></asp:Label>
<br />
<asp:Label id="lblText2" runat="server"></asp:Label>
</form>
</body>
</html>

Screenshot

ASP.NET(vb.net) & ListBox - asp:ListBox
.
.
.
Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (No Ratings Yet)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.