Previous Thread

6/19/2006 4:24:37 AM    Re: How to access datagrid on web page from user control on the same page
Hi Yanesh Tyagi, 
 
You could use FindControl() to find the datagrid which is in aspx page. 
 
Here is the sample code. 
 
Dim conn As System.Data.OleDb.OleDbConnection = New 
 
System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; 
 
Data Source=NWIND.mdb") 
 
Dim da As System.Data.OleDb.OleDbDataAdapter = New 
 
System.Data.OleDb.OleDbDataAdapter("select * from categories", conn) 
 
Dim dataSet As DataSet = New DataSet 
 
da.Fill(dataSet) 
 
Dim dg As DataGrid = CType(Me.Page.FindControl("DataGrid1"), DataGrid) 
 
dg.DataSource = dataSet 
 
dg.DataBind() 
 
-Bhuva 
 
[www.syncfusion.com 
 
http://www.syncfusion.com/faq/aspnet/default.aspx]



6/19/2006 12:39:27 PM    How to access datagrid on web page from user control on the same page
Hi All 
 
have a web page named itemList.aspx. It contains a datagrid (id = 
 
datagrid1). The web form also have a user control named itemSearch.ascx. 
 
This user control have several options to search and a submit button. I 
 
want to change the datasource property of datagrid1 on the click of 
 
submit button. As the datagrid1 is on the itemList.aspx page and the 
 
submit button is on the user control, I connot access the datagrid 
 
directly. Is there any way to acess it from the .vb file of user control? 
 
Thanks 
 
Yanesh Tyagi