Tuesday, 29 July 2014

Remove ComboBox ListItem from specific index position in ASP.NET Ajax

Ajax ComboBox – How to remove ListItem from specific index position programmatically in asp.net ComboBox

  1. <%@ Page Language=“C#” AutoEventWireup=“true” %>

  2. <%@ Register Assembly=“AjaxControlToolkit” Namespace=“AjaxControlToolkit” TagPrefix=“asp” %>

  3. <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
  4. <script runat=“server”>
  5.     protected void Button1_Click(object sender, EventArgs e)
  6.     {
  7.         ComboBox1.Items.RemoveAt(1);
  8.     }
  9. </script>

  10. <html xmlns=“http://www.w3.org/1999/xhtml”>
  11. <head id=“Head1″ runat=“server”>
  12.     <title>Ajax ComboBox - How to remove ListItem from specific index position programmatically in asp.net ComboBox</title>
  13. </head>
  14. <body>
  15.     <form id=“form1″ runat=“server”>
  16.     <div>
  17.         <h2 style=“color:DarkBlue; font-style:italic;”>
  18.             ASP.NET Ajax ComboBox - How to remove ListItem
  19.             <br />from specific index position programmatically
  20.             <br />in asp.net ComboBox
  21.         </h2>
  22.         <hr width=“475″ align=“left” color=“LightBlue” />
  23.         <asp:ToolkitScriptManager ID=“ToolkitScriptManager1″ runat=“server”>
  24.         </asp:ToolkitScriptManager>
  25.         <asp:ComboBox
  26.             ID=“ComboBox1″
  27.             runat=“server”
  28.             DropDownStyle=“DropDown”
  29.             AutoCompleteMode=“None”
  30.             CaseSensitive=“false”
  31.             RenderMode=“Block”
  32.             AppendDataBoundItems=“true”
  33.             AutoPostBack=“false”
  34.             Font-Names=“Comic Sans MS”
  35.             Font-Size=“Medium”
  36.             >
  37.               <asp:ListItem Text=“Crimson”></asp:ListItem>
  38.               <asp:ListItem Text=“HoneyDew”></asp:ListItem>
  39.               <asp:ListItem Text=“LawnGreen”></asp:ListItem>
  40.               <asp:ListItem Text=“Lavender”></asp:ListItem>
  41.               <asp:ListItem Text=“DarkOrchid”></asp:ListItem>
  42.         </asp:ComboBox>
  43.         <br /><br /><br />
  44.         <br /><br /><br />
  45.         <asp:Button
  46.             ID=“Button1″
  47.             runat=“server”
  48.             OnClick=“Button1_Click”
  49.             Text=“Remove ListItem From Index ’1′”
  50.             Height=“45″
  51.             Font-Bold=“true”
  52.             ForeColor=“DeepPink”
  53.             />
  54.     </div>
  55.     </form>
  56. </body>
  57. </html>



No comments:

Post a Comment