Introduction

A DropDownControl is an ASP.NET AJAX extender that can be attached to almost any ASP.NET control to provide a SharePoint-style drop-down menu. The displayed menu is merely another panel or control. The drop-down is activated by left- or right-clicking the attached control. If the behavior is attached to a Hyperlink or LinkButton, clicking on the link itself will operate normally.

DropDown extender control properties

Step 1. Open Visual Studio

Step 2. Drag and drop control from Toolbox.

Now define the DataTable in the Database.

Step 3. Go to Solution Explorer and right-click.

Step 4. Go to the Server Explorer and select the database name.

Step 5. Go to the Default.aspx page and click on the Design option.

Bind the data

Step 6. Select DropDown control and click on DropDownListTask.

Connection String

Step 7. Define the DataSource and Connection String.

Step 8. Go to the Default.aspx page and write the following code.

Code

<title>my ajax application</title>
    </head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:.ConnectionString2 %>"
             SelectCommand="SELECT [CUSTOMERID], [NAME], [PICTURE] FROM [CUSTMERINFORMATIN]">
        </asp:SqlDataSource>
        <div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
        <asp:DropDownList ID="DropDownList1" runat="server"
            DataSourceID="SqlDataSource1" DataTextField="CUSTOMERID"
            DataValueField="CUSTOMERID" Width = "50px" ForeColor ="Blue">
        </asp:DropDownList>
         </ContentTemplate>
        </asp:UpdatePanel>
         <br />
        <br />
         <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1"
                ForeColor ="Red" Font-Bold = "true"
                onselectedindexchanged="GridView1_SelectedIndexChanged">
            </asp:GridView>
             <br />
            <br />
             </div>
    </form>
</body>
</html>

Step 9. Now press F5 and run the application.

OUTDROP1.gif

Step 10. When we click on the DropDown arrow then we see the single record fetch from the table.

DRPOUT12.gif