?
Solved

asp.net vb.net write in a dropdownlist

Posted on 2009-05-08
1
Medium Priority
?
334 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 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month17 days, 3 hours left to enroll

864 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