Click here to Skip to main content
15,867,568 members
Articles / Web Development / ASP.NET
Article

ASP.NET using GridView Control as Lookup

Rate me:
Please Sign up or sign in to vote.
3.36/5 (13 votes)
22 Nov 2008CPOL 181.8K   2.2K   65   35
ASP.NET using GridView control as lookup
Screenshot - Lookup.jpg

Introduction

This simplifies the way to enter lookup values in a textbox.
I have used GridView to return lookup values for FormView control.

You can use the lookup to return a value to any ASP.NET textbox control.

I have used two lookup pages, lookupSupplier.aspx and lookupCategory.aspx. These two lookup pages work for main page default.aspx page which has FormView control that is used for inserting and editing the Products table.

Background

You must know how the GridView control works.

Using the Code

The following is an example of creating a template column for GridView control.

You need to add an ASP.NET hyperlink control for a template column. This hyperlink will be used to return the value(text) in column one (column index 0) of the GridView control.

ASP.NET
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="hlReturnLookupValue" runat="server">Select</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>

Points of Interest

Try to use caching for lookup pages so that lookup pages get opened quickly and work fast. However, this is not essential.

History

I will update this page based on your feedback.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
India India
Developer

Comments and Discussions

 
GeneralWhy not a listbox Pin
Donsw8-Dec-08 3:12
Donsw8-Dec-08 3:12 
GeneralRe: Why not a listbox Pin
Amit K Bhagat23-Oct-09 9:55
Amit K Bhagat23-Oct-09 9:55 
GeneralMy vote of 2 Pin
Ruchit S.24-Nov-08 22:37
Ruchit S.24-Nov-08 22:37 
QuestionHow can I download the video version of this article? Pin
sunisagar20-Nov-08 10:50
sunisagar20-Nov-08 10:50 
AnswerRe: How can I download the video version of this article? Pin
Amit K Bhagat20-Nov-08 17:21
Amit K Bhagat20-Nov-08 17:21 
AnswerRe: How can I download the video version of this article? Pin
Amit K Bhagat21-Nov-08 20:07
Amit K Bhagat21-Nov-08 20:07 
AnswerRe: How can I download the video version of this article? Pin
Amit K Bhagat22-Nov-08 19:17
Amit K Bhagat22-Nov-08 19:17 
GeneralGood one. Pin
Member 382627530-Oct-08 11:30
Member 382627530-Oct-08 11:30 
GeneralRe: Good one. Pin
Amit K Bhagat30-Oct-08 17:09
Amit K Bhagat30-Oct-08 17:09 
QuestionVideo username and password Pin
Arvin Meralpis20-Jun-07 16:31
Arvin Meralpis20-Jun-07 16:31 
AnswerRe: Video username and password Pin
Amit K Bhagat20-Jun-07 22:51
Amit K Bhagat20-Jun-07 22:51 
GeneralRe: Video username and password Pin
Arvin Meralpis25-Jun-07 8:12
Arvin Meralpis25-Jun-07 8:12 
Generalhelp Pin
Chard_olea1-Apr-07 0:45
Chard_olea1-Apr-07 0:45 
GeneralRe: help Pin
Amit K Bhagat1-Apr-07 0:53
Amit K Bhagat1-Apr-07 0:53 
GeneralRe: help Pin
Chard_olea1-Apr-07 1:01
Chard_olea1-Apr-07 1:01 
Generalvideo Pin
Chard_olea31-Mar-07 23:48
Chard_olea31-Mar-07 23:48 
GeneralRe: video Pin
Amit K Bhagat31-Mar-07 23:50
Amit K Bhagat31-Mar-07 23:50 
GeneralRe: video Pin
Amit K Bhagat31-Mar-07 23:54
Amit K Bhagat31-Mar-07 23:54 
GeneralRe: video Pin
Chard_olea31-Mar-07 23:55
Chard_olea31-Mar-07 23:55 
QuestionHow can i fix javascript:// error? Pin
sheahad27-Mar-07 18:58
sheahad27-Mar-07 18:58 
AnswerRe: How can i fix javascript:// error? Pin
Amit K Bhagat27-Mar-07 19:00
Amit K Bhagat27-Mar-07 19:00 
AnswerRe: How can i fix javascript:// error? Pin
Amit K Bhagat27-Mar-07 19:09
Amit K Bhagat27-Mar-07 19:09 
GeneralRe: How can i fix javascript:// error? Pin
sheahad27-Mar-07 19:33
sheahad27-Mar-07 19:33 
GeneralRe: How can i fix javascript:// error? Pin
Amit K Bhagat27-Mar-07 19:45
Amit K Bhagat27-Mar-07 19:45 
GeneralRe: How can i fix javascript:// error? Pin
sheahad27-Mar-07 19:51
sheahad27-Mar-07 19:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.