Repeater Access

G

Guest

I have a page with a Repeater control on it called Repeater1. On that page I
have a User Control I inserted using the HTML Method. Now I want to change
the Repeater's DataSource and then use DataBind method on it if a variable is
defined in the address bar. I've tried alot of things but so far no luck. The
main reason that I have the User Control is becuase it has all the database
controls (dbview, dataset, connection etc) and it also acts as a Menu that is
dynamicly generated based on a database query.

This Method Didn't work

This Function is in the WebForm1 where the Repeater is


public void RepeaterBinding(DataView dbDataViewSource)

{

Repeater1.DataSource = dbDataViewSource;

Repeater1.DataBind();

}




In the user control I tried doing this:



if(selectedcat != null)

{

string thefilter = "DownloadCategory= '"+selectedcat+"' ";

dbDataView.RowFilter = thefilter;

dbDataView.Table = dtDownloads;

DownloadScript.WebForm1 repeaterpage = new WebForm1();

repeaterpage.RepeaterBinding((DataView)this.dbDataView);

Label1.Text = dbDataView.Table.Columns[0].ToString();

}


I get an error saying that there was no instance of an object.
 
K

Karl

A line # would help, with the corresponding line (for all I know, you don't
have something called Label1).

I definately see 1 problem. In the user control, to get a reference to the
page, do this:

WebForm1 repeaterPage = (WebForm1)Page;

as opposed to try and create a new instance of the page..

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top