473,320 Members | 2,094 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Translating ID bound to label in detailsView to NAME basing on different datasource.

Hi there

First of all excuse me posting such simple (I guess) question, but I
didn't find the answer in tutorials.
I have a formView presenting records from some table. one of the fields
is a Category ID, which is a foreign key. in edit template I replace it
with dropdownlist, which is gets this ID, and displays corresponding
name, by getting information from other datasource.

it's possible, since we have 3 properties in ddlist:

( DataSourceID="odsCourseCategories" )
DataTextField="Name"
DataValueField="CourseCategoryID"
SelectedValue='<%# Bind("CourseCategoryID") %>'

DataTextField, and DataValueField which are connected to 'foreign'
dataSource, and SelectedValue which is bound to current dataSource
(inherited from parent FormView).

Now, my problem is simple - how can I achieve the same with simple
label control, on the same field, in ItemTemplate (when I'm not
editing), which doesn't (I guess) have those properties?

Label is bound to Category ID, and I want it to display corresponding
Name.

I know that I could tweak my formview datasource (tableAdapter) to
provide Name also, but I'd like to do it using 2 plain single-table
CRUD datasources.
thanks a lot
greets
Hapiec

Apr 14 '06 #1
2 1593
Hi,
You can't use a label inside a DataList or gridview like this. If you want
to save CategoryID you can use DataKeyNames and CategoryID is not listed
when you use your grid, but your label shows your Name field properly.

Have a nice work,

Aytaç ÖZAY
Software Engineer

"H5N1" <ha****@gmail.com> wrote in message
news:11*********************@g10g2000cwb.googlegro ups.com...
Hi there

First of all excuse me posting such simple (I guess) question, but I
didn't find the answer in tutorials.
I have a formView presenting records from some table. one of the fields
is a Category ID, which is a foreign key. in edit template I replace it
with dropdownlist, which is gets this ID, and displays corresponding
name, by getting information from other datasource.

it's possible, since we have 3 properties in ddlist:

( DataSourceID="odsCourseCategories" )
DataTextField="Name"
DataValueField="CourseCategoryID"
SelectedValue='<%# Bind("CourseCategoryID") %>'

DataTextField, and DataValueField which are connected to 'foreign'
dataSource, and SelectedValue which is bound to current dataSource
(inherited from parent FormView).

Now, my problem is simple - how can I achieve the same with simple
label control, on the same field, in ItemTemplate (when I'm not
editing), which doesn't (I guess) have those properties?

Label is bound to Category ID, and I want it to display corresponding
Name.

I know that I could tweak my formview datasource (tableAdapter) to
provide Name also, but I'd like to do it using 2 plain single-table
CRUD datasources.
thanks a lot
greets
Hapiec



Apr 14 '06 #2
Thanks, so there's no declarative way (ie. through control's
properties) to achieve this, but if so, what is the simplest way to
achieve this programmatically?

I guess I should use the ItemDataBound event, and there, using the
CATEGORY ID value (which is foreign key) bound to label, query the
other objectDataSource (representing CATEGORIES table) to check
corresponding NAME value, and substitute with it the current label
value.

the only problem is I don't know how could I perform programmatic query
on object data source, let say something like:
name = categoriesObjectDataSource.Select("Select Name from Categories
where id=currentID");

I can find only examples with binding ODS to controls, couldn't find
any using it to get some values programmaticaly.
thanks a lot
Hapiec

Apr 14 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jax | last post by:
I have an arraylist of objects. This arraylist is bound to a repeater. That repeater then creates a set of controls like so <asp:repeater id="garmentRepeater" runat="server"...
1
by: Shawn Wildermuth | last post by:
I have a *single* SqlDataSource that loads up a single result set that I show in a GridView. In the GridView, i've added a "Select" button and handling the SelectedItem event. I also have a...
12
by: Jim Hammond | last post by:
I am passing the whole object instead or parameters in my select and update methods. I can get the updated object if I set UpdateMethod, let ASP.NET autogenerate an update button, and then press...
6
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
4
by: Dabbler | last post by:
I'm trying to block out some text by setting Label width attribute which renders as a span tag so that all labels for textfields take up the same amount of space hence the textfields are all...
1
by: Jim McGivney | last post by:
Using VWD I have an aspx page with a GridView and DetailsView controls, each using a different AccessDataSource. The DetailsView is displayed with appropriate data when the user selects one of the...
0
by: mike | last post by:
Hi, When I programatically Bind a DataSource to DetailsView it does not fire "ModeChanged" event. This is first time i am trying to use ASP.NET DetailsView control. I have played with some of the...
4
by: Tomasz Jastrzebski | last post by:
Hello Everyone, I have a GridView control bound to a plain DataTable object. AutoGenerateEditButton is set to true, Edit button gets displayed, and RowEditing event fires as expected.
0
by: Luke Graham | last post by:
hi, I'm coding a social network style application for my dissertation and am having a few problems, I'm using ASP.net and VB.net I have a button within a DetailsView control that I want to trigger...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.