Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

.Net 2.0 datatextfield and object datasource

Hi,

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" >
                    </asp:DropDownList>
0
Gezna
Asked:
Gezna
  • 2
  • 2
1 Solution
 
Bob LearnedCommented:
How does strLang get set?

Bob
0
 
GeznaAuthor Commented:
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")

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

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

Bob
0
 
GeznaAuthor Commented:
ha, ha, I tried exactly that, except I was saying .datavaluefield. no wonder
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now