Program to demonstret Dropdownlist control.
-----------------------------------------DESIGN-----------------------------------------------------
-----------------------------------------code---------------------------------------------------------
-----------------------------------------output----------------------------------------------------
-----------------------------------------DESIGN-----------------------------------------------------
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title>Untitled Page</title>
</head>
<body>
<formid="form1"runat="server">
<asp:LabelID="Label1"runat="server"Text="Nmae of Student"></asp:Label>
<asp:DropDownListID="DropDownList1"runat="server"AutoPostBack="True"
Width="89px">
<asp:ListItem></asp:ListItem>
</asp:DropDownList>
<div>
</div>
<asp:ButtonID="Button1"runat="server"Text="Add Item"Width="98px"/>
<asp:ButtonID="Button3"runat="server"Text="Count Item"Width="91px"/>
<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox>
<br/>
<br/>
<asp:ButtonID="Button2"runat="server"Text="Remove Item"Width="94px"/>
<asp:ButtonID="Button4"runat="server"Text="Select Index"Width="87px"/>
<asp:TextBoxID="TextBox2"runat="server"></asp:TextBox>
<br/>
<br/>
<asp:ButtonID="Button5"runat="server"Text="Select Value"Width="88px"/>
<asp:TextBoxID="TextBox3"runat="server"></asp:TextBox>
<br/>
<br/>
<asp:ButtonID="Button6"runat="server"Text="Seleced Item"Width="88px"/>
<asp:TextBoxID="TextBox4"runat="server"></asp:TextBox>
<br/>
<br/>
<br/>
</form>
</body>
</html>
-----------------------------------------code---------------------------------------------------------
PartialClass _Default
Inherits System.Web.UI.Page
Dim a AsString
ProtectedSub Button1_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles Button1.Click
With DropDownList1.Items
.Add("Bhavik")
.Add("Askar")
.Add("Pratik")
.Add("Ankit")
EndWith
EndSub
ProtectedSub Button3_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles Button3.Click
TextBox1.Text = DropDownList1.Items.Count
EndSub
ProtectedSub Button4_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles Button4.Click
TextBox2.Text = DropDownList1.SelectedIndex.ToString
EndSub
ProtectedSub Button5_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles Button5.Click
TextBox3.Text = DropDownList1.SelectedValue.ToString
EndSub
ProtectedSub Button6_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles Button6.Click
TextBox4.Text = DropDownList1.SelectedItem.Text
EndSub
ProtectedSub Button2_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles Button2.Click
DropDownList1.Items.Remove(DropDownList1.SelectedItem)
EndSub
EndClass -----------------------------------------output----------------------------------------------------
![]() |
|
codestrew |
No comments:
Post a Comment