Using Global Variables in HTML of Web Form

G

Guest

The DBA team at the office controls the naming conventions for the database
structure, but their naming convention are rather tedious. So typically I
create a global module that I use as a mapping file to create constants with
more appropriate field and table names and map them to the table and field
names required by the DB team. But now, using a DataList, I'm having a
problem. How can I use a variable name to indicate the field name in the
HTML that's rendered by the DataList control?

Rather than

<%# DataBiner.Eval(Container.DataItem, "T003_EntityName_String") %>

I want to use

<%# DataBiner.Eval(Container.DataItem, EName) %>

Where EName is a global var defined in a separate module.

Is there a way to do this? I'm getting complaints that EName isn't a valid
column name...

Thanks.

Jerry
 
S

S. Justin Gengo

Jerry,

I think an easier way to do this would be to rename the datatable's fields
when you get them.

Right after you fill your datatable move through each column and name it the
way you want:

DataTable.Columns("T003_EntityName_String").ColumnName = "EName"

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
G

Guest

Can't do that... I have no control over the naming conventions and if I
start changing column names, there will be significant political fall-out.
Unions will file law suits, cats and dogs living together... etc, etc...

But.. I think I figured it out. I created a class with a bunch of public
string vars where I can set the vars equal to whatever they tell me to
actually name the fields. Then I just use an instance of the class in my
code behind and reference it from the HTML. It works.

Now I can code with short names and just fill in the names they want me to
use when they get around to it.

Thanks for the reply.

Jerry
 
S

S. Justin Gengo

Good solution. But I don't understand why you can't just rename the columns.
That doesn't rename them in the actual database...
But I'm glad you found a solution you're happy with!
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
S

S. Justin Gengo

Ahhh, but check out Karl's reply. I think that's the way to go!

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top