471,353 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,353 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 882

"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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Chris | last post: by
2 posts views Thread by Robert | last post: by
3 posts views Thread by Gonza | last post: by
2 posts views Thread by Raymond Du | last post: by
1 post views Thread by webby98 | last post: by
1 post views Thread by jimmysjams | last post: by
1 post views Thread by Johnny Jörgensen | last post: by
5 posts views Thread by brian | last post: by

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.