Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asp:reapeater Problem

Status
Not open for further replies.

dhmfh

Programmer
Nov 28, 2005
69
GB
Hi Guys

I am having trouble trying to display a value from a nested repeater. I can get the value from the parent repeater but not the child. Any ideas?
 
Code as follows

Dim DBConnection As SqlConnection = New SqlConnection(GlobalParameters.DBConnection())
Dim DataAdapter As SqlDataAdapter = New SqlDataAdapter("EXEC DSP_WListApartments", DBConnection)
Dim DataSet As DataSet = New DataSet()
DataAdapter.Fill(DataSet, "ListApartments")

Dim DataAdapter2 As SqlDataAdapter = New SqlDataAdapter("EXEC DSP_WListApartmentPropertyByArea", DBConnection)
DataAdapter2.Fill(DataSet, "ApartmentByArea")
DataSet.Relations.Add("ApartmentByAreaRelationship", DataSet.Tables("ListApartments").Columns("Area_Id"), DataSet.Tables("ApartmentByArea").Columns("Property_Area_Id"))
ListApartments.DataSource = DataSet.Tables("ListApartments")

Page.DataBind()
 
What Function is this code in?
What you need to do is.

Bind the Data for your first repeater
In the OnItemDataBound event of your parent DataRepeater you need to get a reference to the DataRepeater in your current row in the parent DataRepeater, then bind that.

Here is a sample of something I did with a DataList and a DataGrid, but it's the same idea.

Code:
public void BindAccessoryGrid(object sender, DataListItemEventArgs e)
{
string sKey;
			// see what type of row (header, footer, item, etc.) caused the event
			if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
			{

				DatabaseFunctions handle = new DatabaseFunctions();

				System.Web.UI.WebControls.Label oLabel;
				oLabel = ((System.Web.UI.WebControls.Label)(e.Item.FindControl("lblPhoneID")));

				sKey = oLabel.Text;
				
					// Get reference to datagrid control in this row

				System.Web.UI.WebControls.DataGrid oGrid;

				oGrid = ((System.Web.UI.WebControls.DataGrid)(e.Item.FindControl("dgAccessories")));

				iSiteID = Convert.ToInt32(Request.Cookies["SiteID"].Value);
                iCarrierID = DatabaseFunctions.GetCarrierID(Convert.ToString(Request.Cookies["CartID"].Value));

				DataSet ds = handle.GetPhoneAccessories(iSiteID, iCarrierID, Convert.ToInt32(sKey));

                if (ds.Tables[0].Rows.Count > 0)
                {
                    oGrid.DataSource = ds;
                    oGrid.DataBind();
                }


			}

}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top