Best Practices: Table of IDs

S

Sarmatia

I have a table of ID vaules that are related to lookup tables.

I created a DataAccess component from wich the ObjectDataSource gets a
typed datatable. A GridView is bound to that ObjectDataSource and
allows Edit and Delete.

On the same page is the means to add a new record (since the GridView
does not support that ... but that's another rant) via several
DropDownLists bound to other ObjectDataSources.


The issue now is, what is the best way to display the lookup values in
the table? Options are:
1) Return the lookup values with the typed datatable. This seems to
unnecessarily link the table with which I want to interact to the
lookup tables.

2) Use the value from the main table to get the values form the
ObjectDataSources that are already on the page. This seems like "the
right way to do it" but how? I can't bind the Labels in the GridView to
anything but the fields in the tabe to which that is bound. Do I have
to add a DropDownList to get the lookup value then use that for the
label? (I don't want to display a drop down list if it's not meant to
be edited)

Any advice would be much appreciated.
 
S

Sarmatia

Nevermind. I figured out an acceptable solution.

On the Label's DataBinding even, look up the value from the ddl and
replace it.

protected void lblAcctNumb_DataBinding(object sender, EventArgs e)
{
if (sender is Label)
{
//lblAcctNumb is inside the GridView
Label lbl = (Label)sender;
string txt = lbl.Text;
//ddlAccount is outside the GridView
ListItem li = ddlAccount.Items.FindByValue(txt);
lbl.Text = li.Text;
}
}


Thoughts?
 
S

Sarmatia

Nope.

The next Label that needs to be changed gets its value from a drop down
lis that is not populated yet.


grrrrrrrr
 

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

Top