Solved

asp.net vb.net write in a dropdownlist

Posted on 2009-05-08
1
324 Views
Last Modified: 2012-05-06
I need show some items in a ddl, but i need user overwrite some text if necessary.
0
Comment
Question by:rflorencio
1 Comment
 
LVL 5

Accepted Solution

by:
Buginator earned 500 total points
ID: 24334378
Hi,

take a look at my code:
// ASPX file: (main parts)
 

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title></title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

    

        <asp:DropDownList ID="DropDownList1" runat="server">

            <asp:ListItem>text1</asp:ListItem>

            <asp:ListItem>text2</asp:ListItem>

        </asp:DropDownList>

        <br />

        <br />

        Edit chosen text:<br />

        New value:

        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

&nbsp;<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />

    

    </div>

    </form>

</body>

</html>
 
 
 

// THE CODE BEHIND FILE FOR THE ASPX PAGE:
 

Imports System

Imports System.Collections.Generic

Imports System.Linq

Imports System.Web

Imports System.Web.UI

Imports System.Web.UI.WebControls
 

Public Partial Class dropdownlist_text_edit

    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

        

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)

        Dim ID As Integer = DropDownList1.SelectedIndex

        Dim newValue As [String] = TextBox1.Text

        

        ' Update chosen dropdownlist item

            

        DropDownList1.Items(ID).Text = newValue

    End Sub

End Class

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now