Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

ASP.NET using GridView Control as Lookup

0.00/5 (No votes)
22 Nov 2008 1  
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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here