Click here to Skip to main content
Click here to Skip to main content
Go to top

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

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)

Share

About the Author

Amit K Bhagat
Web Developer
India India
Developer

Comments and Discussions

 
Generalvideo PinmemberChard_olea31-Mar-07 23:48 
GeneralRe: video PinmemberAmit K Bhagat31-Mar-07 23:50 
GeneralRe: video PinmemberAmit K Bhagat31-Mar-07 23:54 
GeneralRe: video PinmemberChard_olea31-Mar-07 23:55 
QuestionHow can i fix javascript:// error? Pinmembersheahad27-Mar-07 18:58 
AnswerRe: How can i fix javascript:// error? PinmemberAmit K Bhagat27-Mar-07 19:00 
AnswerRe: How can i fix javascript:// error? PinmemberAmit K Bhagat27-Mar-07 19:09 
GeneralRe: How can i fix javascript:// error? Pinmembersheahad27-Mar-07 19:33 
GeneralRe: How can i fix javascript:// error? PinmemberAmit K Bhagat27-Mar-07 19:45 
GeneralRe: How can i fix javascript:// error? Pinmembersheahad27-Mar-07 19:51 

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.

| Advertise | Privacy | Mobile
Web01 | 2.8.140926.1 | Last Updated 23 Nov 2008
Article Copyright 2007 by Amit K Bhagat
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid