473,396 Members | 1,875 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,396 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 937

"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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
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...
0
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
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,...

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.