Hello all

I have 3 pages in my application
all 3 pages have gridview with same id, i want to bind data from 3 different tables to each 3 gridviews.
i want to create universal databind procedure to bind data to gridview in a class
i am using this line of code in my class

VB Code:
  1. Public sub bind(byval sql as string)
  2.   sda = New SqlDataAdapter(sql, strConn)
  3.    sda.Fill(ds, "mytable")
  4.   GridView1.DataSource = ds.Tables("mytable").DefaultView
  5.   GridView1.DataBind()
  6. end sub
i am passing sql string in page1 pageload
i am calling this class procedure in page load of page1 by creating object instance of the class
VB Code:
  1. obj.bind(Select * from CustomerDetails)
But it is giving an error
object reference not set to an instance of object

how can i take referene of the gridview control present in page1 to the class


Kindly help me to solve this

Thanks in advance