Solved

asp.net vb.net write in a dropdownlist

Posted on 2009-05-08
1
323 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 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

9 Experts available now in Live!

Get 1:1 Help Now