473,729 Members | 2,309 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="o dsCourseCategor ies" )
DataTextField=" Name"
DataValueField= "CourseCategory ID"
SelectedValue=' <%# Bind("CourseCat egoryID") %>'

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 1609
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.c om> wrote in message
news:11******** *************@g 10g2000cwb.goog legroups.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="o dsCourseCategor ies" )
DataTextField=" Name"
DataValueField= "CourseCategory ID"
SelectedValue=' <%# Bind("CourseCat egoryID") %>'

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 programmaticall y?

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 objectDataSourc e (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 = categoriesObjec tDataSource.Sel ect("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
4009
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" OnItemCommand="Repeater_ButtonClick"><HeaderTemplate><asp:Label id="Label1" style="Z-INDEX: 101; LEFT: 250px; POSITION: absolute; TOP: 80px" runat="server Width="200px" Height="50px" Font-Names="Impact" Font-Size="Large">Garments on...
1
10071
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 DetailsView (though FormView has this same issue) where I want to be able to set the current item to bind to from the DataSource. All the examples I've seen use two data sources and on every *select* they do another round-trip to the Database (which...
12
8698
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 update after making changes, but I don't want that update button. How can I get the updated object when the user presses one of my other action buttons?
6
2882
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 and the coresponding 'Id' from the lookup table is to be inserted into the field of the new record. I have two simple tables. "tblPerson" is the data table. The lookup
4
6340
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 aligned but for some reason the width is being ignored in IE 6 even though it works in Firefox. Is there some bug associated with this and maybe the Doctype specification? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"...
1
3482
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 Grid's rows. In the DetailsView I would like the user to be able to select the sex (Female, Male, Unknown) by clicking a button on a RadioButtonList control. To do this I make a template row for the DetailsView, I place a RadioButtonList in the...
0
2550
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 sample provided by Microsoft and other comminity sites. Most of the samples were using Databinding using a DesignTime "SqlDataSource" Control and assigning its ID to DataSourceID property of DetailsView. However, in all of my application we DO...
4
26704
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
999
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 an Insert for a Datasource that is also within the DetailsView There is an OnClick event handler for the button but I'm having problems finding the datasource to trigger it the code I'm using is Dim DataSource As SqlDataSource =...
0
8917
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8761
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9281
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9142
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.