473,288 Members | 1,745 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,288 software developers and data experts.

How do you do this? Simple ASP.NET GridView question

I do a lot of winforms programming in C# and VB.NET, but not I've been asked
to do an ASP.NET application, and that's a first for me. So I hope you will
bear with this basic question, because I'm really puzzled.

I've got an SQL Server 2005 DB, and for the sake of simplification, we can
say that I've got two tables, tblBooks and tblAuthors. tblBooks contains an
integer column called iAuthorID, and tblAuthors contain an integer field
called iAuthorID and a string field called strAuthorName. The two iAuthorID
fields are of course linked through foreign/primary key relationship.

I want to bind an editable gridview to tblBooks and let the user see and
change the data. So I've got a datasource set to tblBooks, and the contents
of the table is shown. the iAuthorID column shows the integer value of the
iAuthorID field. However, I would of course like to show the Authors NAME
instead - collected from tblAuthors.

I've converted the iAuthorID column to a template field, and by exchanging
the EditItemTemplate Textbox with a ComboBox, I can databind the column to
the ID and Name fields in tblAuthors.

But how do I show the author name when the gridview is NOT in Edit mode? I
cannot - as far as I can tell - use the Label control in the templatefields
ItemTemplate for that. The label text can only be bound to the iAuthorID
field in tblBooks (which it should be), but this value cannot be used to get
the value from another tables fields? I cannot use the formatting options
for this, I guess?

I don't like webforms - everything is much simpler in winforms... :-(

But I would really appreciate it if somebody could tell me the solution to
this problem, because I've exhausted all my ideas....

Cheers,
Johnny J.
Jun 27 '08 #1
1 930

"Johnny Jörgensen" <jo**@altcom.sewrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
I don't like webforms - everything is much simpler in winforms... :-(

But I would really appreciate it if somebody could tell me the solution to
this problem, because I've exhausted all my ideas....
You should post to a donet.Webform or dontnet.ASP NG, which is part of
msnews.microsoft.com.

Jun 27 '08 #2

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

Similar topics

4
by: Chris | last post by:
Hi, I read about client callback and i have a question. Assume the option "sorting" is set in a gridview. Each time the user clicks on a fieldname, the data are sorted. My question is: are...
2
by: Robert | last post by:
I have a question regarding the gridview. Does the gridview persist the entire datasource in the viewstate? For example my datasource is returning 100 records, but my gridview only displays 10....
3
by: Gonza | last post by:
Hi group, i have a question relatred to gridview and postback (i should probably know this by now, considering i've been working with .net for a few years now, but baahh). Why could a gridview...
3
by: KarthikChennappan | last post by:
In my application i am using dotnet gridview control. Fetch the values from SQL DB and display it in gridview. below the gridview i have one button control. Question is: 1.I need to add a row...
2
by: Raymond Du | last post by:
Hi, I am looking for a way to use Ajax inside gridview. I am not talking about putting a gridview inside an updatepanel and refresh the gridview, I want to use Ajax on per row basis, when user...
1
by: webby98 | last post by:
I have an issues using LINQ and nested gridview. Let me explain, Gridview A are the for grouping. And Gridview B are place in between Gridview A to display list data relate to Gridview A...
1
by: jimmysjams | last post by:
I'm modifying someone else's code and I have hit a snag. I don't want to rewrite what's already there but I might have to. I have a gridview, in the gridview is a set number of columns that...
1
by: Johnny Jörgensen | last post by:
I do a lot of winforms programming in C# and VB.NET, but not I've been asked to do an ASP.NET application, and that's a first for me. So I hope you will bear with this basic question, because I'm...
5
by: brian | last post by:
I have a gridview that will contain 5000 + rows that is initially loaded into a dataset and bound to a gridview. On the form I have textboxes and dropdown list's I use to let the user fill in and...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
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: 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)...

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.