.Net 2.0 datatextfield and object datasource

Posted on 2006-06-07
Last Modified: 2008-03-06

I have a dropdown list that is being populated by an object datasource (.net 2.0)

The problem is that the datavaluefield is dependent on the user's language, so I need a way to get either a public value from the .vb page, or at a function or something, but nothing seems to work.

Basically if the public variable strLang = e then I want strDescE and if strLang = f then I want strDescF. Is there a way to do this with the new datasourceid field already set???

<asp:DropDownList ID="ddlDistrict"  DataSourceID="ObjectDataSourceDistrict" runat="server" DataTextField="intDistrictcd" DataValueField="strDescE" AutoPostBack="True" >
Question by:Gezna
    LVL 96

    Expert Comment

    by:Bob Learned
    How does strLang get set?


    Author Comment

    It is a public variable on the codebehind that is set from the session.

    The session variable could be used directly, I don't care. Basically I just need a way to say

    datatextfield="if strlang='f' then strDescF else strDescE"

    'Code behind

    Public strLang as String
    strLang = Session("headStrLang")

    LVL 96

    Accepted Solution

    This is how you would do it in the code-behind:

    If Session("headStrLang") = "e" Then
       Me.ddlDistrict.DataTextField = "Field1"
       Me.ddlDistrict.DataTextField = "Field2"
    End If


    Author Comment

    ha, ha, I tried exactly that, except I was saying .datavaluefield. no wonder

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    iTextSharp 3 33
    Contant UI messages in .NET 1 22
    SQL QUERY to Table question 32 60
    Help needed on website authentication 7 37
    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    732 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

    21 Experts available now in Live!

    Get 1:1 Help Now