Click here to Skip to main content
15,885,366 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.1K   2.2K   65  
ASP.NET using GridView control as lookup
Partial Class Controls_Lookup
    Inherits System.Web.UI.UserControl
    Public Property Height() As String
        Get
            Return Me.ViewState("Height")
        End Get
        Set(ByVal value As String)
            Me.ViewState("Height") = value
        End Set
    End Property

    Public Property Width() As String
        Get
            Return Me.ViewState("Width")
        End Get
        Set(ByVal value As String)
            Me.ViewState("Width") = value
        End Set
    End Property

    Public Property Url() As String
        Get
            Return Me.ViewState("Url")
        End Get
        Set(ByVal value As String)
            Me.ViewState("Url") = value
        End Set
    End Property
    Public Property LookupWindowName() As String
        Get
            Return Me.ViewState("LookupWindowName")
        End Get
        Set(ByVal value As String)
            Me.ViewState("LookupWindowName") = value
        End Set
    End Property
    Public Property ReturnToControlID() As String
        Get
            Return Me.ViewState("ReturnToControlID")
        End Get
        Set(ByVal value As String)
            Me.ViewState("ReturnToControlID") = value
        End Set
    End Property

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim sJS As String
        sJS = "javascript:w=window.open(" & _
                                """" & ResolveClientUrl(Me.Url) & "?setLookupValueToControlID=" & Me.Parent.FindControl(Me.ReturnToControlID).ClientID & """," & _
                                """" & Me.LookupWindowName & """," & _
                                """" & "location=0,status=0,scrollbars=yes,resizable=yes," & _
                                "width=" & Me.Width & ",height=" & Me.Height & """" & _
                                ");w.focus();"
        Me.Lookup.NavigateUrl = "javascript://"
        Me.Lookup.Attributes.Add("onclick", sJS)
    End Sub
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