{"action":"created","issue":{"url":"https://api.github.com/repos/silviomoreto/bootstrap-select/issues/720","labels_url":"https://api.github.com/repos/silviomoreto/bootstrap-select/issues/720/labels{/name}","comments_url":"https://api.github.com/repos/silviomoreto/bootstrap-select/issues/720/comments","events_url":"https://api.github.com/repos/silviomoreto/bootstrap-select/issues/720/events","html_url":"https://github.com/silviomoreto/bootstrap-select/issues/720","id":41614780,"number":720,"title":"Selectpicker is not working in asp","user":{"login":"omerzia","id":5998373,"avatar_url":"https://avatars.githubusercontent.com/u/5998373?v=3","gravatar_id":"","url":"https://api.github.com/users/omerzia","html_url":"https://github.com/omerzia","followers_url":"https://api.github.com/users/omerzia/followers","following_url":"https://api.github.com/users/omerzia/following{/other_user}","gists_url":"https://api.github.com/users/omerzia/gists{/gist_id}","starred_url":"https://api.github.com/users/omerzia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omerzia/subscriptions","organizations_url":"https://api.github.com/users/omerzia/orgs","repos_url":"https://api.github.com/users/omerzia/repos","events_url":"https://api.github.com/users/omerzia/events{/privacy}","received_events_url":"https://api.github.com/users/omerzia/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2014-09-01T07:42:19Z","updated_at":"2015-01-27T09:18:30Z","closed_at":null,"body":"Hi all,\r\n\r\nasp list item are not being viewed on aspx page.\r\n\r\n  `<asp:DropDownList ID=\"DropDownList2\" CssClass=\"selectpicker\" data-style=\"btn-danger\" runat=\"server\"> `\r\n     `<asp:ListItem>Action</asp:ListItem> `\r\n   `<asp:ListItem>Another action</asp:ListItem> `\r\n     `<asp:ListItem>Something else here</asp:ListItem> `\r\n     `</asp:DropDownList> `\r\n```javascript\r\n<script type=\"text/javascript\">\r\n       $(document).ready(function () {\r\n           $('.selectpicker').selectpicker('');\r\n       });\r\n    </script>\r\n```\r\nAny ideas?"},"comment":{"url":"https://api.github.com/repos/silviomoreto/bootstrap-select/issues/comments/71614069","html_url":"https://github.com/silviomoreto/bootstrap-select/issues/720#issuecomment-71614069","issue_url":"https://api.github.com/repos/silviomoreto/bootstrap-select/issues/720","id":71614069,"user":{"login":"seanbotha123","id":5496698,"avatar_url":"https://avatars.githubusercontent.com/u/5496698?v=3","gravatar_id":"","url":"https://api.github.com/users/seanbotha123","html_url":"https://github.com/seanbotha123","followers_url":"https://api.github.com/users/seanbotha123/followers","following_url":"https://api.github.com/users/seanbotha123/following{/other_user}","gists_url":"https://api.github.com/users/seanbotha123/gists{/gist_id}","starred_url":"https://api.github.com/users/seanbotha123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seanbotha123/subscriptions","organizations_url":"https://api.github.com/users/seanbotha123/orgs","repos_url":"https://api.github.com/users/seanbotha123/repos","events_url":"https://api.github.com/users/seanbotha123/events{/privacy}","received_events_url":"https://api.github.com/users/seanbotha123/received_events","type":"User","site_admin":false},"created_at":"2015-01-27T09:18:30Z","updated_at":"2015-01-27T09:18:30Z","body":"Been using bootstrap select with asp.net for a while now, code to make it work, while also adding 'option group' functionality to asp dropdownlist: ( VB code)\r\n```\r\nPublic Class DropDownListAdapter\r\n    Inherits System.Web.UI.WebControls.Adapters.WebControlAdapter\r\n    Protected Overrides Sub RenderContents(writer As HtmlTextWriter)\r\n       \r\n            Dim list As DropDownList = TryCast(Me.Control, DropDownList)\r\n\r\n            Dim currentOptionGroup As String\r\n            Dim renderedOptionGroups As New List(Of String)()\r\n\r\n            For Each item As ListItem In list.Items\r\n                If item.Attributes(\"OptionGroup\") Is Nothing Then\r\n                    RenderListItem(item, writer)\r\n                Else\r\n                    currentOptionGroup = item.Attributes(\"OptionGroup\")\r\n\r\n                    If renderedOptionGroups.Contains(currentOptionGroup) Then\r\n                        RenderListItem(item, writer)\r\n                    Else\r\n                        If renderedOptionGroups.Count > 0 Then\r\n                            RenderOptionGroupEndTag(writer)\r\n                        End If\r\n\r\n                        RenderOptionGroupBeginTag(currentOptionGroup, writer)\r\n                        renderedOptionGroups.Add(currentOptionGroup)\r\n\r\n                        RenderListItem(item, writer)\r\n                    End If\r\n                End If\r\n            Next\r\n\r\n            If renderedOptionGroups.Count > 0 Then\r\n                RenderOptionGroupEndTag(writer)\r\n            End If\r\n    End Sub\r\n\r\n    Private Sub RenderOptionGroupBeginTag(name As String, writer As HtmlTextWriter)\r\n        writer.WriteBeginTag(\"optgroup\")\r\n        writer.WriteAttribute(\"label\", name)\r\n        writer.Write(HtmlTextWriter.TagRightChar)\r\n        writer.WriteLine()\r\n    End Sub\r\n\r\n    Private Sub RenderOptionGroupEndTag(writer As HtmlTextWriter)\r\n        writer.WriteEndTag(\"optgroup\")\r\n        writer.WriteLine()\r\n    End Sub\r\n\r\n    Private Sub RenderListItem(item As ListItem, writer As HtmlTextWriter)\r\n        writer.WriteBeginTag(\"option\")\r\n        writer.WriteAttribute(\"value\", item.Value, True)\r\n\r\n        If item.Selected Then\r\n            writer.WriteAttribute(\"selected\", \"selected\", False)\r\n        End If\r\n\r\n        For Each key As String In item.Attributes.Keys\r\n            writer.WriteAttribute(key, item.Attributes(key))\r\n        Next\r\n\r\n        writer.Write(HtmlTextWriter.TagRightChar)\r\n        HttpUtility.HtmlEncode(item.Text, writer)\r\n        writer.WriteEndTag(\"option\")\r\n        writer.WriteLine()\r\n    End Sub\r\nEnd Class\r\n```\r\n\r\nthen in the 'App_Browsers\" folder create file \"BrowserFile.browser\" and add this code:\r\n```\r\n<browsers>\r\n  <browser refID=\"Default\">\r\n    <controlAdapters>\r\n      <adapter controlType=\"System.Web.UI.WebControls.DropDownList\" adapterType=\"DropDownListAdapter\" />\r\n    </controlAdapters>\r\n  </browser>\r\n</browsers>\r\n```\r\n\r\nYour program should then understan to use this 'adapter'\r\n\r\nTo use the dropdown from code you add items like this:\r\n```\r\nDim li As New ListItem(\"TEXT\", \"VALUE\")\r\nli.Attributes.Add(\"OptionGroup\", \"OPTION GROUP NAME\")\r\n\r\nDROPDOWNLIST.Items.Add(li)\r\n\r\nDim newLi As New ListItem(\"TEXT\", \"VALUE\")\r\nnewLi.Attributes.Add(\"OptionGroup\", \"OPTION GROUP NAME\")\r\n\r\nnewLi.Selected = True\r\n\r\nDROPDOWNLIST.Items.Add(newLi)\r\n```\r\n\r\nAs far as i know asp dropdownlist automatically renders as <select>, so I don't think that all this is necessary, but I know this code does work. \r\n\r\nGood luck"}}