Dovberman
asked on
How to set the label.text property to the data displayed in a dropdownlist. visual studio 2005
I need to set the label.text property to the data displayed in a dropdownlist.
Me.lblResource.Text = ddlResourceType.DataTextFi eld 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> <br />
<asp:DropDownList ID="ddlResourceType" runat="server" AutoPostBack="True"
DataSourceID="dscResourceT ype"
DataTextField="RT_Name" DataValueField="RT_ID">
</asp:DropDownList>
<asp:SqlDataSource ID="dscResourceType" runat="server"
ConnectionString="<%$ ConnectionStrings:ResFinde rSQLConnec tionString %>"
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_SelectedIn dexChanged (ByVal sender As Object,
ByVal e As System.EventArgs)
Handles ddlResourceType.SelectedIn dexChanged
Me.lblResource.Text = ddlResourceType.DataTextFi eld
Thanks,
Dovberman
Me.lblResource.Text = ddlResourceType.DataTextFi
Source code for the aspx file
<asp:Label ID="lblResourceType" runat="server" Text="Resource Type">
</asp:Label> <br />
<asp:DropDownList ID="ddlResourceType" runat="server" AutoPostBack="True"
DataSourceID="dscResourceT
DataTextField="RT_Name" DataValueField="RT_ID">
</asp:DropDownList>
<asp:SqlDataSource ID="dscResourceType" runat="server"
ConnectionString="<%$ ConnectionStrings:ResFinde
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_SelectedIn
ByVal e As System.EventArgs)
Handles ddlResourceType.SelectedIn
Me.lblResource.Text = ddlResourceType.DataTextFi
Thanks,
Dovberman
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER