473,587 Members | 2,447 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 EditItemTemplat e 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 945

"Johnny Jörgensen" <jo**@altcom.se wrote in message
news:%2******** ********@TK2MSF TNGP06.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.microsof t.com.

Jun 27 '08 #2

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

Similar topics

4
1806
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 the data on each click fetched from the server, or are they 'cached' on the client-side and so avoiding a lot of transferts between server and browser? If not 'cached', would it not bebetter to use the client callback
2
1331
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. Are the other 90 records stored in the viewstate? Thanks.
3
311
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 (regular gridview, no custom controls inside, bound to a list<custom object>) loose it's value after a postback. I know that the datasource is not saved in viewstate, but why are the rows getting cleared???? Thanks in advace Gonzalo, from...
3
1327
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 in gridview without affecting the other values in gridview. (For example i have Five rows in gridview,if i click a button i want to add sixth row with empty textbox control below the fifth row)
2
3536
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 clicks on a dropdownlist on row number x, only row x will be refreshed. Can somebody give me some code samples? TIA
1
1765
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 grouping. Both GridView will need to be populate dynamically on runtime via stored procedure and using LINQ. 1st SPROC are to get the grouping data for Gridview A 2nd SPROC are to get record for Gridview B base on a
1
2779
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 will always be there. On the end of the gridview I need to add columns dynamically. These columns may or may not exist and I don't know how many there will be. The way it is currently programmed, there are 2 gridviews, one for viewing a list and...
1
784
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 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...
5
270
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 click an add button to add new records. As I let users add records I update the SQL backend (insert a record). I want to programattically add a row to the gridview an not having to requery the table reload the dataset and bind each time a...
0
7924
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
7854
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
8349
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
7978
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
8221
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...
1
5722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5395
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3845
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
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.