{"id":2396,"date":"2012-12-19T13:46:01","date_gmt":"2012-12-19T17:46:01","guid":{"rendered":"http:\/\/www.iowawebnet.com\/ein\/?p=2396"},"modified":"2012-12-19T13:49:03","modified_gmt":"2012-12-19T17:49:03","slug":"append-item-at-the-end-of-dropdownlist-vb-net","status":"publish","type":"post","link":"https:\/\/www.iowawebnet.com\/ein\/2012\/12\/append-item-at-the-end-of-dropdownlist-vb-net\/","title":{"rendered":"Add item on the dropdownlist &#8211; VB.NET"},"content":{"rendered":"<pre>\r\nMarkup page\r\n<code>\r\n&lt;!--\r\n'define control -->\r\n&lt;asp:DropDownList ID=\"MySelectionDDL\" runat=\"server\" \r\nAutoPostBack=\"True\" AppendDataBoundItems=\"true\" \r\nDataSourceID=\"MySelectionDS\" DataTextField=\"Text\" DataValueField=\"Value\" \r\nOnDataBound=\"MySelectionDDL_DataBound\">\r\n&lt;!--\r\n'define datasource -->\r\n&lt;asp:SqlDataSource ID=\"MySelectionDS\" runat=\"server\" \r\nConnectionString=\"< %$ ConnectionStrings:my_sql_connection %>\" \r\nSelectCommand=\"SELECT [Text], [Value] FROM [MyTable] ORDER BY [Text]\">\r\n&lt;\/asp:SqlDataSource>\r\n\r\n<\/code>\r\nCode behind\r\n<code>\r\nProtected Sub MySelectionDDLDataBound(ByVal sender As Object, ByVal e As EventArgs)\r\n\r\n'add item at the beginning of the list \r\nMySelectionDDL.Items.Insert(0, New ListItem(\"Please Select\", \"\"))\r\n\r\n'add item at the end of the list (assuming there are 10 records on the list)\r\nMySelectionDDL.Items.Insert(11, New ListItem(\"Other\", \"Other\"))\r\nEnd Sub\r\n<\/code>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Markup page &lt;!&#8211; &#8216;define control &#8211;> &lt;asp:DropDownList ID=&#8221;MySelectionDDL&#8221; runat=&#8221;server&#8221; AutoPostBack=&#8221;True&#8221; AppendDataBoundItems=&#8221;true&#8221; DataSourceID=&#8221;MySelectionDS&#8221; DataTextField=&#8221;Text&#8221; DataValueField=&#8221;Value&#8221; OnDataBound=&#8221;MySelectionDDL_DataBound&#8221;> &lt;!&#8211; &#8216;define datasource &#8211;> &lt;asp:SqlDataSource ID=&#8221;MySelectionDS&#8221; runat=&#8221;server&#8221; ConnectionString=&#8221;< %$ ConnectionStrings:my_sql_connection %>&#8221; SelectCommand=&#8221;SELECT [Text], [Value] FROM [MyTable] ORDER BY [Text]&#8221;> &lt;\/asp:SqlDataSource> Code behind Protected Sub MySelectionDDLDataBound(ByVal sender As Object, ByVal e As EventArgs) &#8216;add item at the beginning of the list [&hellip;]<\/p>\n","protected":false},"author":35,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[85,17,16,52,84],"tags":[19,144,125,22],"class_list":["post-2396","post","type-post","status-publish","format-standard","hentry","category-net-4-0","category-applications","category-net","category-controls","category-vs2010","tag-asp-net","tag-controls","tag-dropdownlist","tag-programming"],"_links":{"self":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/2396"}],"collection":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/comments?post=2396"}],"version-history":[{"count":8,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/2396\/revisions"}],"predecessor-version":[{"id":2404,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/2396\/revisions\/2404"}],"wp:attachment":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/media?parent=2396"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/categories?post=2396"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/tags?post=2396"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}