Click here to Skip to main content
Licence CPOL
First Posted 24 Mar 2007
Views 117,515
Downloads 941
Bookmarked 62 times

ASP.NET using GridView Control as Lookup

By | 22 Nov 2008 | Article
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: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)

About the Author

Amit K Bhagat

Web Developer

India India

Member

Developer

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 5 Pinmemberantonache_radu@yahoo.com19:53 13 Jan '12  
QuestionGridView to return lookup values for a field in GridView control Pinmemberantonache_radu@yahoo.com19:47 13 Jan '12  
AnswerRe: GridView to return lookup values for a field in GridView control PinmemberAmit K Bhagat19:50 13 Jan '12  
GeneralRe: GridView to return lookup values for a field in GridView control Pinmemberantonache_radu@yahoo.com20:04 13 Jan '12  
QuestionC # version Pinmemberalyy040618:55 7 Dec '11  
AnswerRe: C # version PinmemberAmit K Bhagat18:16 9 Dec '11  
GeneralRe: C # version Pinmemberalyy040616:15 26 Apr '12  
GeneralRe: C # version Pinmemberalyy040617:15 26 Apr '12  
GeneralWhy not a listbox PinmemberDonsw3:12 8 Dec '08  
GeneralRe: Why not a listbox PinmemberAmit K Bhagat9:55 23 Oct '09  
GeneralMy vote of 2 PinmemberRuchit Surati22:37 24 Nov '08  
QuestionHow can I download the video version of this article? Pinmembersunisagar10:50 20 Nov '08  
AnswerRe: How can I download the video version of this article? PinmemberAmit K Bhagat17:21 20 Nov '08  
Hello Sunisagar!
 
I will make it available by today and also update the download link.
 
Amit
 
Amit

AnswerRe: How can I download the video version of this article? PinmemberAmit K Bhagat20:07 21 Nov '08  
AnswerRe: How can I download the video version of this article? PinmemberAmit K Bhagat19:17 22 Nov '08  
GeneralGood one. PinmemberMember 382627511:30 30 Oct '08  
GeneralRe: Good one. PinmemberAmit K Bhagat17:09 30 Oct '08  
QuestionVideo username and password PinmemberArvin Meralpis16:31 20 Jun '07  
AnswerRe: Video username and password PinmemberAmit K Bhagat22:51 20 Jun '07  
GeneralRe: Video username and password PinmemberArvin Meralpis8:12 25 Jun '07  
Generalhelp PinmemberChard_olea0:45 1 Apr '07  
GeneralRe: help PinmemberAmit K Bhagat0:53 1 Apr '07  
GeneralRe: help PinmemberChard_olea1:01 1 Apr '07  
Generalvideo PinmemberChard_olea23:48 31 Mar '07  
GeneralRe: video PinmemberAmit K Bhagat23:50 31 Mar '07  

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

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120529.1 | Last Updated 23 Nov 2008
Article Copyright 2007 by Amit K Bhagat
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid