mattfox77
asked on
Cannot set DataSource for nested Repeater
I am trying to create a nested repeater that uses the same BLL layer as the parent repeater.
I have a method which retrieves the data for the nested repeater based on the value of a field retrieved from the parent repeater by a button.
When the repeaters are separated everything works fine - the ItemCommand event of the parent repeater sends the value to the method and the child repeater(not nested) retrieves the correct data. However when I move the child repeater inside the parent repeater, Visual Studio complains that the repeater doesn't exist in the current context - intellisense doesn't recognize the child repeater or DataSource for it.
Help!!
I have a method which retrieves the data for the nested repeater based on the value of a field retrieved from the parent repeater by a button.
When the repeaters are separated everything works fine - the ItemCommand event of the parent repeater sends the value to the method and the child repeater(not nested) retrieves the correct data. However when I move the child repeater inside the parent repeater, Visual Studio complains that the repeater doesn't exist in the current context - intellisense doesn't recognize the child repeater or DataSource for it.
Help!!
ASKER
I've amended my code to build the nested repeater datasource with a method, but now I am getting an error on compile:
Error 6 No overload for method 'GetJobActivities' takes '0' arguments
the method refers to a method in the BLL which calls a tableadapter in the DAL
Error 6 No overload for method 'GetJobActivities' takes '0' arguments
the method refers to a method in the BLL which calls a tableadapter in the DAL
Code Behind:
protected JobActivities.taJobActivitiesDataTable allActs = null;
protected JobActivities.taJobActivitiesDataTable GetJobActivities(string JobID)
{
if(allActs == null)
{
JobsBLL JobActLogic = new JobsBLL();
allActs = JobActLogic.GetJobActivities();
}
allActs.DefaultView.RowFilter = "Job_CD = " + JobID;
return allActs;
}
Nested Repeater DataSource:
<asp:Repeater ID="repeaterChild" runat="server" DataSource='<%# GetJobActivities((string) Eval("Job_Cd")) %>' >
BLL Class Method:
private taJobActivitiesTableAdapter _jobsAdapter = null;
protected taJobActivitiesTableAdapter jAdapter
{
get
{
if (_jobsAdapter == null)
_jobsAdapter = new taJobActivitiesTableAdapter();
return _jobsAdapter;
}
}
[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, false)]
public JobActivities.taJobActivitiesDataTable GetJobActivities(string JobID)
{
return jAdapter.GetJobActivities(JobID);
}
ASKER
ragi0017:
I've read through the codeproject code you posted, as well as many others similar - I'm not declaring my datasources in the code - Im using a 3 tier architecture, and when I did try to use the example code, I could not define the datasource for the nested repeater!! Im missing maybe a declaritive or something??
Anyway, now Ive got it down to a method (previous attempts at this would not work but Im trying again anyway) -got to get past the 0 arguments error!
I've read through the codeproject code you posted, as well as many others similar - I'm not declaring my datasources in the code - Im using a 3 tier architecture, and when I did try to use the example code, I could not define the datasource for the nested repeater!! Im missing maybe a declaritive or something??
Anyway, now Ive got it down to a method (previous attempts at this would not work but Im trying again anyway) -got to get past the 0 arguments error!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That's it! I changed it to:
allActs = JobActLogic.GetJobActiviti es(JobID);
and it works!
thank you!
allActs = JobActLogic.GetJobActiviti
and it works!
thank you!
http://www.codeproject.com/KB/webforms/Server_Nested_Repeaters.aspx