Click here to Skip to main content
Licence CPOL
First Posted 24 Mar 2007
Views 114,280
Downloads 806
Bookmarked 61 times

ASP.NET using GridView Control as Lookup

By Amit K Bhagat | 22 Nov 2008
ASP.NET using GridView control as lookup
1 vote, 11.1%
1
2 votes, 22.2%
2
2 votes, 22.2%
3
1 vote, 11.1%
4
3 votes, 33.3%
5
3.06/5 - 9 votes
μ 3.06, σa 2.55 [?]
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.com20:53 13 Jan '12  
QuestionGridView to return lookup values for a field in GridView control Pinmemberantonache_radu@yahoo.com20:47 13 Jan '12  
AnswerRe: GridView to return lookup values for a field in GridView control PinmemberAmit K Bhagat20:50 13 Jan '12  
GeneralRe: GridView to return lookup values for a field in GridView control Pinmemberantonache_radu@yahoo.com21:04 13 Jan '12  
QuestionC # version Pinmemberalyy040619:55 7 Dec '11  
AnswerRe: C # version PinmemberAmit K Bhagat19:16 9 Dec '11  
GeneralWhy not a listbox PinmemberDonsw4:12 8 Dec '08  
GeneralRe: Why not a listbox PinmemberAmit K Bhagat10:55 23 Oct '09  
GeneralMy vote of 2 PinmemberRuchit Surati23:37 24 Nov '08  
QuestionHow can I download the video version of this article? Pinmembersunisagar11:50 20 Nov '08  
AnswerRe: How can I download the video version of this article? PinmemberAmit K Bhagat18:21 20 Nov '08  
AnswerRe: How can I download the video version of this article? PinmemberAmit K Bhagat21:07 21 Nov '08  
AnswerRe: How can I download the video version of this article? PinmemberAmit K Bhagat20:17 22 Nov '08  
GeneralGood one. PinmemberMember 382627512:30 30 Oct '08  
GeneralRe: Good one. PinmemberAmit K Bhagat18:09 30 Oct '08  
QuestionVideo username and password PinmemberArvin Meralpis17:31 20 Jun '07  
When I click on the link to download the video, the browser prompts for a username and password.
AnswerRe: Video username and password PinmemberAmit K Bhagat23:51 20 Jun '07  
GeneralRe: Video username and password PinmemberArvin Meralpis9:12 25 Jun '07  
Generalhelp PinmemberChard_olea1:45 1 Apr '07  
GeneralRe: help PinmemberAmit K Bhagat1:53 1 Apr '07  
GeneralRe: help PinmemberChard_olea2:01 1 Apr '07  
Generalvideo PinmemberChard_olea0:48 1 Apr '07  
GeneralRe: video PinmemberAmit K Bhagat0:50 1 Apr '07  
GeneralRe: video PinmemberAmit K Bhagat0:54 1 Apr '07  
GeneralRe: video PinmemberChard_olea0:55 1 Apr '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
Web02 | 2.5.120210.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