Click here to Skip to main content
13,248,107 members (36,998 online)
Click here to Skip to main content
Add your own
alternative version


65 bookmarked
Posted 24 Mar 2007

ASP.NET using GridView Control as Lookup

, 22 Nov 2008
Rate this:
Please Sign up or sign in to vote.
ASP.NET using GridView control as lookup
Screenshot - Lookup.jpg


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.


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:HyperLink ID="hlReturnLookupValue" runat="server">Select</asp:HyperLink>

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.


I will update this page based on your feedback.


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

You may also be interested in...


Comments and Discussions

QuestionC # version Pin
alyy04067-Dec-11 19:55
memberalyy04067-Dec-11 19:55 
AnswerRe: C # version Pin
Amit K Bhagat9-Dec-11 19:16
memberAmit K Bhagat9-Dec-11 19:16 
GeneralRe: C # version Pin
alyy040626-Apr-12 17:15
memberalyy040626-Apr-12 17:15 
GeneralRe: C # version Pin
alyy040626-Apr-12 18:15
memberalyy040626-Apr-12 18:15 
Hi Amit,

I get "Microsoft JScript runtime error: Object doesn't support this property or method"
<a id="GridView1_ctl19_hlReturnLookupValue" onclick="winOpener=window.self.opener;winOpener.document.getElementById('FormView1_IFX_LOCATIONTextBox').value='';;" href="javascript://">Select</a>
when i press the select link in my GridView.

Can you help on this? Is there anything I miss out?

Best Regards,

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.

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