Solved

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

Posted on 2007-04-01
2
219 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Exceptions 3 44
VB.NET (2008) - Refactoring Question 2 21
SqlDependency to get update from sql to my c# app 2 39
VB.NET 2008 Publish Error 2 27
IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 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