Click here to Skip to main content
15,896,606 members
Articles / Web Development / ASP.NET

ASP.NET using GridView Control as Lookup

Rate me:
Please Sign up or sign in to vote.
3.36/5 (13 votes)
22 Nov 2008CPOL 182.7K   2.2K   65  
ASP.NET using GridView control as lookup
Imports Microsoft.VisualBasic
Imports System.Web.HttpContext
Public Class Tools
    Public Shared Sub BuildLookupValueReturnControl(ByVal e As GridViewRow, ByVal LinkControlId As String)
        If e.RowType = DataControlRowType.DataRow Then
            Dim hl As New HyperLink
            Dim js As String
            hl = CType(e.FindControl(LinkControlId), HyperLink)
            js = BuildJS_ReturnLookupValue(Current.Request.QueryString("setLookupValueToControlID"), e.Cells(0).Text)
            hl.NavigateUrl = "javascript://"
            hl.Attributes.Add("onclick", js)
        End If
    End Sub
    Public Shared Function BuildJS_ReturnLookupValue(ByVal controlID As String, ByVal valueToSet As String) As String
        Dim s As String

        s = "winOpener=window.self.opener;" & _
            "winOpener.document.getElementById('" & controlID & "').value='" & valueToSet & "';" & _
            "window.close();"
        Return s
    End Function
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
India India
Developer

Comments and Discussions