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



- <%@ Page Language=“C#” AutoEventWireup=“true” %>
- <%@ Register Assembly=“AjaxControlToolkit” Namespace=“AjaxControlToolkit” TagPrefix=“asp” %>
- <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
- <script runat=“server”>
- protected void Button1_Click(object sender, EventArgs e)
- {
- ComboBox1.Items.RemoveAt(1);
- }
- </script>
- <html xmlns=“http://www.w3.org/1999/xhtml”>
- <head id=“Head1″ runat=“server”>
- <title>Ajax ComboBox - How to remove ListItem from specific index position programmatically in asp.net ComboBox</title>
- </head>
- <body>
- <form id=“form1″ runat=“server”>
- <div>
- <h2 style=“color:DarkBlue; font-style:italic;”>
- ASP.NET Ajax ComboBox - How to remove ListItem
- <br />from specific index position programmatically
- <br />in asp.net ComboBox
- </h2>
- <hr width=“475″ align=“left” color=“LightBlue” />
- <asp:ToolkitScriptManager ID=“ToolkitScriptManager1″ runat=“server”>
- </asp:ToolkitScriptManager>
- <asp:ComboBox
- ID=“ComboBox1″
- runat=“server”
- DropDownStyle=“DropDown”
- AutoCompleteMode=“None”
- CaseSensitive=“false”
- RenderMode=“Block”
- AppendDataBoundItems=“true”
- AutoPostBack=“false”
- Font-Names=“Comic Sans MS”
- Font-Size=“Medium”
- >
- <asp:ListItem Text=“Crimson”></asp:ListItem>
- <asp:ListItem Text=“HoneyDew”></asp:ListItem>
- <asp:ListItem Text=“LawnGreen”></asp:ListItem>
- <asp:ListItem Text=“Lavender”></asp:ListItem>
- <asp:ListItem Text=“DarkOrchid”></asp:ListItem>
- </asp:ComboBox>
- <br /><br /><br />
- <br /><br /><br />
- <asp:Button
- ID=“Button1″
- runat=“server”
- OnClick=“Button1_Click”
- Text=“Remove ListItem From Index ’1′”
- Height=“45″
- Font-Bold=“true”
- ForeColor=“DeepPink”
- />
- </div>
- </form>
- </body>
- </html>



No comments:
Post a Comment