How to Add DropDownList ListItem Add in Asp.Net C#

ADD DROPDOWNLIST  LISTITEM


A DropDownList is also commonly known as combo box.

 It can contain multiple data members, but unlike a normal list box the users can choose only one value from this control.


Asp.Net dropdownlist web server control enables user to select a single item from list item collection. 


Though the functionality of this DropDownList is much like a Single Row Select List Box, a DropDownList can save a lot of GUI space as it is rendered on a Single line and is expanded only when the user clicks on the Control.


dropdownlist display a collection of list items. list item have two main properties Text and Value.


 Text represent the content which display on browser and Value represent a hidden text associated with specific list item.


we can populate dropdownlist from various data sources. 


we also can add dropdownlist list item manually by write them between opening and closing tags. 



   First  Select - DropDownList  From ToolBox - Select  Edit Items






Html  Coding


<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <table><tr><td>
        <asp:Label ID="Label1" runat="server" Text="Country Name"></asp:Label>
        </td><td>
            <asp:DropDownList ID="DropDownList1" runat="server">
                <asp:ListItem>Select  Country</asp:ListItem>
                <asp:ListItem>Australia</asp:ListItem>
                <asp:ListItem>Bhudan</asp:ListItem>
                <asp:ListItem>Canada</asp:ListItem>
                <asp:ListItem>Germany</asp:ListItem>
                <asp:ListItem>India</asp:ListItem>
                <asp:ListItem>USA</asp:ListItem>
                <asp:ListItem>New Zeland</asp:ListItem>
            </asp:DropDownList>
        </td></tr></table>
    </div>
    </form>
</body>



</html>

  
  Next - Click ADD Button  Required  ListItem  Selected





     
    
      Select  ListItem  Text  Value Change  Required  Name
         
       Bottom & up Key used to Move the selected ListItem






        
               
       Select - One Listitem(Australia) -  Move to Top 






    

Next - Click - OK - Button - Go to  Design Page





             






 Next - F5 Run the Program  - Select  Drop Down Key   Show  List Items

OUTPUT





0 comments:

Post a Comment