开发者

jquery drop down for selecting multiple values

i want to develop dropdown inside a check box . this url shows me how to do it. http://dropdown-check-list.go开发者_JS百科oglecode.com/svn/trunk/demo.html but the code isnt given how to implement it in project. i need to bind my datatable to this dropdow. and once user selects a value and clicks on the button in .cs file i should be able to get all these values

if any one knows how to slove this issue let me know

thank you


This is a jquery plugin that does the transformation client side. You haven't tagged your question to indicate what server side technology you are using, but from your description I infer it is ASP.NET.

Here's a sample page I've setup illustrating how to achieve the functionality you are looking for:

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Linq" %>

<script type="text/C#" runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            listBox.DataSource = new[] { "Aries", "Taurus", "Gemini" };
            listBox.DataBind();
        }
    }

    protected void BtnClick(object sender, EventArgs e)
    {
        var selectedItems = (from item in listBox.Items.Cast<ListItem>()
                 where item.Selected
                 select item.Text).ToArray();
        result.Text = "You selected: ";
        result.Text += string.Join(",", selectedItems);
    }
</script>
<!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></title>
    <script type="text/javascript" src="scripts/jquery.js"></script>
    <script type="text/javascript" src="scripts/ui.core.js"></script>
    <script type="text/javascript" src="scripts/ui.dropdownchecklist.js"></script>
    <script type="text/javascript">
        $(function() {
            $('.listBox').dropdownchecklist();
        });
    </script>
    <link rel="stylesheet" href="css/ui.dropdownchecklist.css" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ListBox ID="listBox" runat="server" SelectionMode="Multiple" CssClass="listBox" />
        <asp:LinkButton ID="btn" runat="server" Text="Click me" OnClick="BtnClick" />
        <asp:Label ID="result" runat="server" />
    </div>
    </form>
</body>
</html>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜