Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to set the label.text property to the data displayed in a dropdownlist. visual studio 2005

Posted on 2007-04-01
2
Medium Priority
?
227 Views
Last Modified: 2013-11-26
I need to set the label.text property to the data displayed in a dropdownlist.

Me.lblResource.Text = ddlResourceType.DataTextField returns the field name instead of the field value.

Source code for the aspx file

    <asp:Label ID="lblResourceType" runat="server" Text="Resource Type">
    </asp:Label>&nbsp;<br />
   
    <asp:DropDownList ID="ddlResourceType" runat="server" AutoPostBack="True"
      DataSourceID="dscResourceType"
      DataTextField="RT_Name" DataValueField="RT_ID">
    </asp:DropDownList>
   
    <asp:SqlDataSource ID="dscResourceType" runat="server"
      ConnectionString="<%$ ConnectionStrings:ResFinderSQLConnectionString %>"
        SelectCommand="SELECT [RT_ID], [RT_Name] FROM [Resource_Types]
      ORDER BY [RT_Name]" DataSourceMode="DataReader">
    </asp:SqlDataSource>

Source code for the aspx.vb file

    Protected Sub ddlResourceType_SelectedIndexChanged(ByVal sender As Object,
      ByVal e As System.EventArgs)
      Handles ddlResourceType.SelectedIndexChanged

        Me.lblResource.Text = ddlResourceType.DataTextField

Thanks,

Dovberman
0
Comment
Question by:Dovberman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
JackOfPH earned 500 total points
ID: 18834722
Me.lblResource.Text = ddlResourceType.Text
0
 

Author Comment

by:Dovberman
ID: 18835949
I tried that. It returns the index value. Yet the dropdown list displays the text of the RT_Name field.
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

636 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