Sunday, April 7, 2013

drop down list with search asp.net OR search option in dropdownlist asp.net

Here in this post i will show how Search Option in ASP.NET dropdownlist .....

OutPut :





 Default.aspx Page




<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="DDL_Search_Option.Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Scearch Option for DropDownList in asp.net</title>
    <link href="Styles/themes/redmond/jquery-ui.css" rel="stylesheet" type="text/css" />
    <link href="Styles/udf/ufd-base.css" rel="stylesheet" type="text/css" />
    <link href="Styles/udf/plain/plain.css" rel="stylesheet" type="text/css" />
    <script src="Scripts/jquery-1.4.4.js" type="text/javascript"></script>
    <script src="Scripts/jquery-ui-1.8.13.js" type="text/javascript"></script>
    <script src="Scripts/jquery.ui.ufd.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("#SelectCountry").ufd({ log: true });
        });

        function GetSelectedVal(id) {
            var val = $(id + 'option:selected').text();
            var value = $(id + 'option:selected').val();
            $('[id$=lblSelectedValues]').text('Value = ' + value + ", Text = " + val);
        }    
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <center>
        <div>
        <br/>Selected 
            <asp:Label ID="lblSelectedValues" runat="server" Text="-" Font-Bold="True" Font-Italic="False"
                ForeColor="Red"></asp:Label>
            <br /><br />
            Select Country :
            <br />
            <br />
            <asp:DropDownList ID="SelectCountry" name="SelectCountry" runat="server" ClientIDMode="Static"
                OnSelectedIndexChanged="SelectCountry_SelectedIndexChanged" onchange="GetSelectedVal(this)"
                AutoPostBack="false">
                <asp:ListItem Text="-- Select --" Value="0"></asp:ListItem>
                <asp:ListItem Text="China" Value="1"></asp:ListItem>
                <asp:ListItem Text="India" Value="2"></asp:ListItem>
                <asp:ListItem Text="United States" Value="3"></asp:ListItem>
                <asp:ListItem Text="Indonesia" Value="4"></asp:ListItem>
                <asp:ListItem Text="Brazil" Value="5"></asp:ListItem>
                <asp:ListItem Text="Pakistan" Value="6"></asp:ListItem>
                <asp:ListItem Text="Bangladesh" Value="7"></asp:ListItem>
                <asp:ListItem Text="Nigeria" Value="8"></asp:ListItem>
                <asp:ListItem Text="Russia" Value="9"></asp:ListItem>
                <asp:ListItem Text="Japan" Value="10"></asp:ListItem>
            </asp:DropDownList>
        </div>
    </center>
    </form>
</body>
</html>

In Default.aspx page :


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace DDL_Search_Option
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
 
        protected void SelectCountry_SelectedIndexChanged(object sender, EventArgs e)
        {
            string selectedval = SelectCountry.SelectedValue;
        }
    }
}

  DownLoad From HERE

No comments:

Post a Comment