473,474 Members | 1,822 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to get more data from a gridview's underlying datasource?

Hi there,

I have got a gridview showing a display-name of a person and keeping its
person-id as value accessible.

Now I am wondering how I can get to his age, if this field isn't visible in
the gridview but definied in the underlying datasource (a dataset)?

Has anyone got a idea on this problem?

Thank you for your quick answers!

Sincerly yours,
Curious SQL-Trigger
Jul 23 '06 #1
4 7242
The grid items (row) have property DataItem. You need to typecast it to the
type representing a row in your datasource.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

"Curious Trigger" <Cu*************@nospam.gmx.netwrote in message
news:eQ**************@TK2MSFTNGP02.phx.gbl...
Hi there,

I have got a gridview showing a display-name of a person and keeping its
person-id as value accessible.

Now I am wondering how I can get to his age, if this field isn't visible
in the gridview but definied in the underlying datasource (a dataset)?

Has anyone got a idea on this problem?

Thank you for your quick answers!

Sincerly yours,
Curious SQL-Trigger

Jul 23 '06 #2
Eliyahu, thanks a lot for this tipp. I will give it a try and tell you the
outcoming.

Curious Trigger

"Eliyahu Goldin" <re*************@monarchmed.comschrieb im Newsbeitrag
news:eJ*************@TK2MSFTNGP05.phx.gbl...
The grid items (row) have property DataItem. You need to typecast it to
the type representing a row in your datasource.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

"Curious Trigger" <Cu*************@nospam.gmx.netwrote in message
news:eQ**************@TK2MSFTNGP02.phx.gbl...
>Hi there,

I have got a gridview showing a display-name of a person and keeping its
person-id as value accessible.

Now I am wondering how I can get to his age, if this field isn't visible
in the gridview but definied in the underlying datasource (a dataset)?

Has anyone got a idea on this problem?

Thank you for your quick answers!

Sincerly yours,
Curious SQL-Trigger


Jul 23 '06 #3
There's a couple of ways you can add this. I assume you are using some
version of Visual Studio 2005/Express... In the designer, the smart
tag/menu has an "Edit Items" command that will open a new window and
you can add the item there (add a BoundField). In the properties, put
the column name from your query into the "DataTextField" property.
This is the easiest of methods...

If you are more comfortable with the code or are not using an IDE like
VS 2005, then locate the control in your source and add the following
to <asp:GridView- <Columns>

<asp:BoundField DataField="data_age" HeaderText="Age"
SortExpression="data_age"/>

Replace 'data_age' with whatever your query is returning.

Curious Trigger wrote:
Hi there,

I have got a gridview showing a display-name of a person and keeping its
person-id as value accessible.

Now I am wondering how I can get to his age, if this field isn't visible in
the gridview but definied in the underlying datasource (a dataset)?

Has anyone got a idea on this problem?

Thank you for your quick answers!

Sincerly yours,
Curious SQL-Trigger
Jul 24 '06 #4
Thanks for this info!

What I am searching for is how I can get to a column of a gridview, if this
column is defined in the underlying datasource but in the gridview it is
invisible. It is strange that I am not able to access this invisible piece
of information; at least not through the gridview. I have still to test the
advice of Mr. Goldin: getting the actual datarow of the underlying
datasource sounds very reasonable for me.

Yours Curious Trigger

"Greg9Strat" <gr********@comcast.netschrieb im Newsbeitrag
news:11*********************@i3g2000cwc.googlegrou ps.com...
There's a couple of ways you can add this. I assume you are using some
version of Visual Studio 2005/Express... In the designer, the smart
tag/menu has an "Edit Items" command that will open a new window and
you can add the item there (add a BoundField). In the properties, put
the column name from your query into the "DataTextField" property.
This is the easiest of methods...

If you are more comfortable with the code or are not using an IDE like
VS 2005, then locate the control in your source and add the following
to <asp:GridView- <Columns>

<asp:BoundField DataField="data_age" HeaderText="Age"
SortExpression="data_age"/>

Replace 'data_age' with whatever your query is returning.

Curious Trigger wrote:
>Hi there,

I have got a gridview showing a display-name of a person and keeping its
person-id as value accessible.

Now I am wondering how I can get to his age, if this field isn't visible
in
the gridview but definied in the underlying datasource (a dataset)?

Has anyone got a idea on this problem?

Thank you for your quick answers!

Sincerly yours,
Curious SQL-Trigger

Jul 24 '06 #5

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

Similar topics

6
by: Nalaka | last post by:
Hi, I have a gridView (grid1), which as a templateColumn. In the template column, I have put in a gridView (grid2) and a ObjectDataSource (objectDataSource2). Question is... How to I pass the...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
0
by: Greg Ramsey | last post by:
Hi - I'm a real newbie to ASP . . so please forgive me. . . and please point me in the right direction for how to do this "the right way" . . :) Using Northwind DB as an example, I have a...
5
by: sutphinwb | last post by:
Hi - This could be a simple question. When I relate two tables in a datasetet, how do I get that relation to show up in a GridView? The only way I've done it, is to create a separate table in the...
14
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control...
0
by: Adam Sandler | last post by:
Hello, Prior to posting I looked at http://groups.google.com/group/ microsoft.public.dotnet.framework.aspnet/browse_thread/thread/ d8d5ae243614085e/d4fd6c4a5aa56f75 ...
6
by: rcoco | last post by:
Hi, I have a datagrid that is ment to insert data. But when I run the form only the header appears. I would like some advise from you all and solve this problem I'm using visual studio 2003. My...
1
by: weird0 | last post by:
I have created a GridView and dynamically added data to it by creating a DataTable(as advised) and bound it with a reader. Then, assigned the DataSource of GridView to DataTable. But even that aint...
1
by: Dave | last post by:
I'm having problems getting the GridView to reliably display a large amount of data (50,000+ rows). I am working my way through the excellent book “Real World ASP.NET Best Practices” by Farhan...
0
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...
1
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.