Solved

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

Posted on 2007-04-01
2
212 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
2 Comments
 
LVL 15

Accepted Solution

by:
JackOfPH earned 250 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 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