Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

911 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

16 Experts available now in Live!

Get 1:1 Help Now