Repeater control in another repeater control

Hi,

I want Repeater control in another repeater control but it is not working
Code :
<asp:Repeater ID=CourseMaster Runat=server >
<ItemTemplate>
<table border=0 cellpadding=0 cellspacing=0 style="font-family:tahoma;font-size:12">
<tr>
<td >&nbsp;<b</b></td>
</tr>
<tr>
<td>
<asp:repeater ID="CourseDetails" Runat=server>
<ItemTemplate>
<table >
<tr>
<td </td>
<td ></td>
</tr>
</table>
</ItemTemplate>
</asp:repeater></td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>

But one error occurs
Name 'CourseDetails' is not declared.
CourseDetails is the name of the second repeater
Help Pls
0
arjunender
2/3/2004 11:16:23 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

10 Replies
1455 Views

Similar Articles

[PageSpeed] 26

CourseDetails control belongs to the outer repeater control so it does not exist untill the outer repeater has some items created. 

You can access the inner repeater only going through the Item property of the outer repeater given it has some items created. Let me know if you need more info. Post your code in that case.
Bug [MCSD]
0
Bug_Bugger
2/3/2004 12:03:52 PM
Actually i want to display details like this from database

Class1
raj
satish
Class2
vinod
kumar
classes in one repeater and names in another repeater
Is it possible with repeater controls
Thanks
0
arjunender
2/4/2004 5:55:49 AM
Yes, it is possible. Simplest way is to create a dataset containing two tables: one for classes and another - for class members. Then define the relationship between the tables.

Bind you outer repeater to the dataset specifying the data member as being the first table. Bind the inner repeater to the GetChildRows method of the datarow, i.e.

<asp:Repeater ID=CourseMaster Runat=server >
<ItemTemplate>
<table border=0 cellpadding=0 cellspacing=0 style="font-family:tahoma;font-size:12">
<tr>
<td >&nbsp;<b</b></td>
</tr>
<tr>
<td>
<asp:repeater ID="CourseDetails" Runat=server DataSource='<%#Ctype(Container.DataItem, DataRow).GetChildRows()%>'>
<ItemTemplate>
<table >
<tr>
<td </td>
<td ></td>
</tr>
</table>
</ItemTemplate>
</asp:repeater></td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>

Bug [MCSD]
0
Bug_Bugger
2/4/2004 9:09:42 AM
Hi,

Can you please give some clue how to do this
I am trying but some where it is getting wrong
Thanks for Helping
0
arjunender
2/4/2004 9:14:01 AM
I am posting the source code

Can you help me where i am getting wrong
<%@ Import Namespace="System.Data.SqlClient"%>
<%@ Import Namespace="System.Data"%>
<%@ Page Language="vb" AutoEventWireup="true" %>
<html>
<head>
<script runat="server">
Dim cn as SqlConnection
Sub Page_Load()
cn = New SqlConnection("Server=60.0.0.2;Uid=smarteach;Pwd=smarteach;Database=smarteach")
If Not (IsPostBack) then
Course_Master()
End If
End Sub
Sub Course_Master()
Dim ds as New Dataset()
Dim rs as New SqlDataAdapter("SELECT Student_ID,Course_Name, Course_Id FROM Student_Course_Master " ,cn)
rs.fill(ds,"Course_Master")
CourseMaster.DataSource=DS.Tables("Course_Master").DefaultView
CourseMaster.DataBind()
End Sub
function Get_Course_Details(course as string,student as string)
Dim ds1 as New Dataset()
Dim rs1 as New SqlDataAdapter("SELECT Lecture_Category_Name, Lesson_Status FROM Student_Lecture_Log WHERE (Student_Id = '" & Student & "') AND (Course_Id = '" & course & "')",cn)
rs1.fill(ds1,"Course_Details")
CourseDetails.DataSource=DS1.Tables("Course_Details").DefaultView
CourseDetails.DataBind()
End function
</script>
</head>
<body >
<h3><font face="Verdana">Student Course Status</font></h3>
<form runat=server ID="Form1">
<asp:Repeater ID=CourseMaster Runat=server >
<ItemTemplate>
<table border=0 cellpadding=0 cellspacing=0 style="font-family:tahoma;font-size:12">
<tr>
<td >&nbsp;<%# DataBinder.Eval(Container.DataItem, "Course_Name")%></td>
<td><%# Get_Course_Details(DataBinder.Eval(Container.DataItem, "Course_ID"),DataBinder.Eval(Container.DataItem, "student_id") )%></td>
</tr>
<tr>
<td><asp:repeater ID="CourseDetails" Runat=server >
<ItemTemplate><asp:TextBox ID=dd Runat=server></asp:TextBox></ItemTemplate>
<ItemTemplate>
<table >
<tr>
<td ><%# DataBinder.Eval(Container.DataItem, "Lecture_Category_Name")%></td>
<td ><%# DataBinder.Eval(Container.DataItem, "Lesson_Status")%></td>
</tr>
</table>
</ItemTemplate>
</asp:repeater></td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>

<asp:DataList ></asp:DataList>


</form>
</body>
</html>

Get_Course_Details is a function where i am sending parameters and getting the details from another table

Please Help
0
arjunender
2/4/2004 9:44:10 AM
I have misleaded you a bit before, here what you need to do:


1. Signature of the Page_Load sub is not right, change it to:
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
2. Inside the repeater, instead of:
<%# Get_Course_Details(DataBinder.Eval(Container.DataItem, "Course_ID"),DataBinder.Eval(Container.DataItem, "student_id") )%>
include two hidden fields, their values will be used to extract the details later:
<input type="hidden" id="Course_Id" value='<%#DataBinder.Eval(Container.DataItem, "Course_ID")%>' runat="server">
<input type="hidden" id="Student_Id" value='<%#DataBinder.Eval(Container.DataItem, "Student_ID")%>' runat="server">

3. Modify the Get_Course_Details to return a table rather then doing a databinding:


function Get_Course_Details(course as string,student as string) as DataTable
Dim ds1 as New Dataset()
Dim rs1 as New SqlDataAdapter("SELECT Lecture_Category_Name, Lesson_Status FROM Student_Lecture_Log WHERE (Student_Id = '" & Student & "') AND (Course_Id = '" & course & "')",cn)
rs1.fill(ds1,"Course_Details")
return DS1.Tables("Course_Details")
End function

4. Create an ItemDataBound event handler for the outer repeater:

Private Sub CourseMaster_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles CourseMaster.ItemDataBound
CType(e.Item.FindControl("CourseDetails"), Repeater).DataSource = Get_Course_Details(CType(e.Item.FindControl("Course_Id"), HtmlInputHidden).Value, CType(e.Item.FindControl("Course_Id"), HtmlInputHidden).Value)
CType(e.Item.FindControl("CourseDetails"), Repeater).DataBind()
End Sub

It will work now, have fully tested it here
Bug [MCSD]
0
Bug_Bugger
2/4/2004 1:24:12 PM
Hi,

I am trying to achieve something similar, infact I have been trying to use bits of your code to make mine work... But still no luck :(
Here is the error:
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 43: Sub subBindCvNotes(sender as Object, e as RepeaterItemEventArgs)
Line 44:
Line 45: Dim intCvId = CType(e.Item.FindControl("frmIdCvAttachment"), HtmlInputHidden).Value
Line 46:
Line 47: Dim myCvNotesDataView as DataView = dsCv.Tables("tblNotes").DefaultView


and the source code for the page:
<%@ Page Language="VB" Debug="true" %>

<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">
Dim dsCv as New DataSet()
Sub Page_Load(sender as Object, e as EventArgs)

subBindCv()

End Sub

Sub subBindCv()
Dim conSql as New SqlConnection(ConfigurationSettings.AppSettings("strCon"))

Dim strSqlCv as String = "SELECT tblCvAttachments.idCvAttachment, tblCvAttachments.strName, tblCvAttachments.txtComments, tblFileUpload.idFileUpload, tblFileUpload.strFileName, tblFileUpload.intSize " _
& "FROM tblCvAttachments " _
& "INNER JOIN tblFileUpload ON tblCvAttachments.fk_idFileUpload = tblFileUpload.idFileUpload ;"

Dim strSqlCvNotes as String = "SELECT tblNotes.fk_id, tblNotes.fk_table, tblNotes.txtNote " _
& "FROM tblCvAttachments, tblNotes;"
Dim mySqlCvCommand as New SqlCommand(strSqlCv, conSql)
Dim mySqlCvDataAdapter as New SqlDataAdapter(mySqlCvCommand)

Dim mySqlCvNotesCommand as New SqlCommand(strSqlCvNotes, conSql)
Dim mySqlCvNotesDataAdapter as New SqlDataAdapter(mySqlCvNotesCommand)

conSql.Open()

mySqlCvDataAdapter.Fill(dsCv, "tblCvAttachments")
mySqlCvNotesDataAdapter.Fill(dsCv, "tblNotes")

conSql.Close()

repCvs.DataSource = dsCv.Tables("tblCvAttachments")
repCvs.DataBind()

End Sub

Sub subBindCvNotes(sender as Object, e as RepeaterItemEventArgs)
Dim intCvId = CType(e.Item.FindControl("frmIdCvAttachment"), HtmlInputHidden).Value

Dim myCvNotesDataView as DataView = dsCv.Tables("tblNotes").DefaultView
myCvNotesDataView.RowFilter = "fk_id = " & intCvId

CType(e.Item.FindControl("repCvNotes"), Repeater).DataSource = myCvNotesDataView
CType(e.Item.FindControl("repCvNotes"), Repeater).DataBind

End Sub
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Repeater</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<asp:Repeater id="repCvs" runat="server" OnItemDataBound="subBindCvNotes">
<ItemTemplate>
<table width="100%" border="1" cellpadding="5" cellspacing="0" bordercolor="#000000" class="itemTableStyle">
<tr class="itemTableHeader">
<td colspan="2">CV added as file attachment by ??? of ??? on ???. </td>
</tr>
<tr>
<td width="95">Name on CV : </td>
<td width="400"><%#Container.DataItem("strName")%></td>
</tr>
<tr>
<td>Download : </td>
<td><asp:Button CssClass="formButton" ID="butDownloadCv" runat="server" Text="Download" />
<%#Container.DataItem("strFileName")%> <%#Container.DataItem("intSize")%> bytes </td>
</tr>
<tr>
<td colspan="2"> Comment : </td>
</tr>
<tr>
<td colspan="2"><%#Container.DataItem("txtComments")%></td>
</tr>
<tr>
<td colspan="2"><asp:Button CssClass="formButton" ID="butCvInterviewRequest" runat="server" Text="Click here to..." />
Request an interview, reference or offer the job to this person <br>
<br>
<asp:Button CssClass="formButton" ID="butCvReject" runat="server" Text="Click here to..." />
Reject this applicant.</td>
</tr>
</table>
<br>
<input type="hidden" id="frmIdCvAttachment" value="<%#Container.DataItem("idCvAttachment")%>" runat="server">
<table width="100%" border="1" cellpadding="5" cellspacing="0" bordercolor="#000000" class="itemTableStyle">
<tr>
<td colspan="2" class="itemTableHeader"><%#Container.DataItem("strName")%> CV Notes : </td>
</tr>
<asp:Repeater id="repCvNotes" runat="server">
<ItemTemplate>
<tr>
<td colspan="2"><%#Container.DataItem("txtNote")%></td>
</tr>
</ItemTemplate>
</asp:Repeater>
<tr>
<td colspan="2">If you wish to add a note to this vacancy please use the form below :<br />
<asp:TextBox id="frmNote1" runat="server" CssClass="form" TextMode="MultiLine" Rows="5" Columns="60"></asp:TextBox>
<asp:Button id="butAddNote1" runat="server" CssClass="formButton" Text="Submit"></asp:Button></td>
</tr>
</table>
<br>
<hr size="1" />
<br>
</ItemTemplate>
</asp:Repeater>
</body>
</html>

Thanks!!
- Carl S
0
MrCarl
2/4/2004 5:14:18 PM
Your problems are:

1. Use the <form> tag on your page
2. Instead of:
<input type="hidden" id="frmIdCvAttachment" value="<%#Container.DataItem("idCvAttachment")%>" runat="server">
Use:
<input type="hidden" id="frmIdCvAttachment" value='<%#Container.DataItem("idCvAttachment")%>' runat="server">
(apostrophie around the data binding bit rather than quotes.

If you fix those you code will work
Cheers

Bug [MCSD]
0
Bug_Bugger
2/4/2004 7:19:10 PM
Haha!! So close yet so far away...

Thanks ever so much :)
- Carl S
0
MrCarl
2/5/2004 8:48:14 AM
Yes it working 

Thanks for helping Nikolai Oulmassov
0
arjunender
2/7/2004 5:19:19 AM
Reply:

Similar Artilces:

How do I control one control from another control?
I have a page page1.aspx which is within a master page. On page I have a table with two cells. Within each cell I have placed two controls (ascx) that I have developed. Now I'd like to be able to get these two controls to interact. One needs to update the other. One has some search criteria that the other one needs to update its gridview. One needs to make the other visible/not visible at certain times. Out of the box neither control can see each other at all. Is there a good article or someplace I can find some information on how to do this?  AllAboutFocus.com. Information Technolo...

refering to controls in a repeater control
Hey, (this is an example situation) I have a repeater control which displays a textbox. As the repeater control is 'run' when the page is loaded. I'd like to give a unique id to each textbox. ie: name1, name2, name3, name4 etc. And I'd also like to store the number of times the repeater control is 'iterated' through. I imagine the best way to store the number of times is to either return a values with my select query (Stored Procedure), or to increment a cached int each time I run through the repeater control. How would I assign a 'unique' id to each textbox? Thanks ...

Get control in repeater control
Dear all, I want to use HtmlControls.HtmlTableCell in repeater control but i cant not access it,  in my table in Repeater Control,  i have 2 "td" which on page_load, i want to show only 1 of them depend on condition given. But i cant do it. This is my code : <asp:repeater id="repeaterViewNew" runat="server">                   <HeaderTemplate>                      <table width="100%" cellpadding="1" cellspacing="1">   &...

Repeater control in a composite control...
How do I put a repeater control in a composit control. Currently, I putting textbox, dropdowns, etc. There is a very small different between the dropdownlist and repeater if both of then are databound. Basically, all you need to cater for is databinding of the Repeater during the databinding of your composite control BugBug [MCSD]...

how to radiobuttonlist control in repeater control?
Hi there, I tried this code for nested repeater control.  The following code is working fine. Only the thing is  I want radio buttons instead of bullet points.Could any  one help me in  that?  In reapeater.aspx<%@ Page Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true" CodeFile="repeater.aspx.cs" Inherits="repeater" Title="Untitled Page" %> <%@ Import Namespace="System.Data" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentP...

Responding to control in Repeater Control
I'm attempting to respond to events by a dropdownlost/checkbox/radiobutton and I am having trouble getting the code to do this to work. For the aspx file I have tried setting the function to call in the dropdownlist in the OnSelectedIndexChanged property yet. That causes the module to have an unhandled error when I attempt to view it. This also happens when I put it in the repeater controls OnItemCommand="SetNewUpline", the module becomes unloadable. My function looks like         private void SetNewUpline(object sender, RepeaterCommandEventArgs e) ...

select control in a repeater control
Hi I have a repeater control which data are selected that way:  Strsql = "SELECT T_PRODUIT.NO_PRODUIT, T_PRODUIT.UNITE, T_PRODUIT.NO_CATEGORIE, T_PRODUIT.NO_CSBE,T_PRODUIT.NOUVEAU,T_PRODUIT.ID_PRODUIT, " & _ "CASE WHEN IMAGE IS NULL THEN 'Aucun.gif' ELSE IMAGE END AS IMAGE1, T_PRODUIT.NOM, " & _ "T_PRODUIT.DESCR, T_PRODUIT.DETAIL,T_FOURNISSEUR_PRODUIT.NO_FOURNISSEUR_PRODUIT, T_FOURNISSEUR_PRODUIT.PRIX, T_FOURNISSEUR_PRODUIT.PRIX_LISTE, " & _ "T_FOURNISSEUR.NOM as FNOM, T_FOURNISSEUR.NO_F...

Trying to load a control into a control from another control
Exactly as the subject states, I'm trying to load a control into another control from a control loaded into a page, I keep getting this error from the code I have below. I've also tried the findcontrol but it keeps coming up null. (67): 'System.Web.UI.UserControl' denotes a 'class' where a 'variable' was expected UserControl ut = ((webcontrols.BrowseItems)UserControl).LoadControl("BrowseItems"); ((webcontrols.BrowseItems)UserControl).pnl_browse_main.Controls.Add(ut); This is how we Load User controls into a content place holder. try { UserCont...

Repeat a Repeater Control?
I have a stored procedure that returns one big table with Employee names, phone numbers, and their state.  I need to generate different tables (or GridViews, or Repeaters... not sure) for each state.  Here's an example: My table hasID     Employee_Name    Phone_Number     State I need my web form to look like this: CaliforniaID    Employee_Name   Phone_NumberID    Employee_Name   Phone_NumberID    Employee_Name   Phone_Num...

Calendar Control inside Repeater, Handling Child control events in parent Data Control
Hi all,I've been researching a problem i have for a couple of days now and i'm still not sure how to even start to handle it.I'm essentially trying to build a page that will display custom form fields/controls for individual items/rows inside a repeater.I've got a fairly complex calendar i need to have working inside each individual row of the Repeater. The calendar is set up to fire the following events: OnDayRender="Calendar2_DayRender" OnSelectionChanged="Calendar2_SelectionChanged" OnVisibleMonthChanged="Calendar2_VisibleMonthChanged"My first question is how do i go about handling these...

Data presentation control in another Data presentation control
 Hello,I want to make a menu with datalist or gridview control.Basically,the menu will be like this,Categories     Sub Categories.For example, for COMPUTING category there will be NOTEBOOKS DESKTOPS etc.There will be a image for CATEGORIES and linkbuttons with Subcategories.If I put a datalist inside a datalist and a link button inside the second datalist visually it satisfies my need.However,CommandArguments come from database to linkbutton.Andwhen one of these command buttons is cliked it must go to proper page.I dont know how to wrie an event_handler ,specifically, for...

nesting a datalist control in a repeater control
Hi I need to display a report in the following format: Heading1 item one for heading1 item two for heading1 item three for heading1 ..... Heading2 item one for heading2 item two for heading2 item three for heading2 .... Heading3 item one for heading3 item two for heading3 item three for heading3 ..... I have tried use a repeater control for displaying the Headings and a datalist control to display the items for each heading. The problem is that I couldn't nest a datalist control between the repeater's ItemTemplate tag. Any help for nesting A...

Custom Control Inside a Repeater Control
I have a repeater control on the main page and would like to load a custom user control inside the repeater control. The custom user control is basically a GridView. A few values will need to be passed to the custom user control to define the where clause for the GridView DataSet. Can anyone provide me with or point me to a simple example of this functionality?Allan Horwitz Nevermind, I just put a GridView inside the Repeater Control tags and used the OnItemDataBound event to get the variables.Allan Horwitz...

How to access a control inside a Repeater control?
 <asp:Repeater ID="Repeater1" runat="server"> <HeaderTemplate><ul></HeaderTemplate> <ItemTemplate><li><asp:Image id="Image1" runat="server" /> </li></ItemTemplate> <FooterTemplate></ul></FooterTemplate> </asp:Repeater>   Protected Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles Repeater1.ItemDataBound Dim Image1 As WebControls.Image Image1 = CType(e.Item.FindCo...

Web resources about - Repeater control in another repeater control - asp.net.presentation-controls

Repeaters - Wikipedia, the free encyclopedia
Kyle Halsted, Sonia Logan, and Michael Weeks are inmates at a rehabilitation facility. Bob Simpson, the administrator, tasks them with apologizing ...

Animal Repeater Memory Game HD Free Lite - for iPad for iPad on the iTunes App Store
Get Animal Repeater Memory Game HD Free Lite - for iPad on the App Store. See screenshots and ratings, and read customer reviews.

Consumers warned to beware of illegal mobile phone repeaters
Use of devices sold online as legitimate solution is in fact dangerous and can land you in jail, regulator warns.

Grim repeater: HIV on the rise
CANDLES flicker in the chilly night air as Jesse Hooper appears on the giant cinema screen overlooking Melbourne&#8217;s Federation Square. He&#8217;s ...

Telstra suspects underbelly of illegal repeaters
'Tens' busted each year. Telstra engineers suspect a "vast" undercurrent of illegal repeaters are causing issues for the carrier's Next G mobile ...

Hands on: Cel-Fi mobile repeater
If your home is a mobile blackspot then a Cel-Fi mobile repeater might help you stay connected.

Amped Wireless R20000G, SR20000G, and UA2000: Routers, Repeaters, and Adapters
... and throughput when pointed at your wireless router/access point. Rounding out the review, Amped sent a third product, their SR20000G repeater, ...

Photon heralds entanglement in new quantum repeater
... For ordinary electrical wires (such those used for ethernet), signals can travel long distances because they're boosted by means of repeaters ...

Celebrity Rehab Repeaters
Kate Middleton Bikini Photos 50 Shades of Grey Hollywood Couples Red Carpet The Kardashians Best Dressed Hot Bodies Celebrity Kids News Sightings ...

Computer networking: wireless networks (wifi), routers, repeaters & more - CNET Reviews
Computer networking reviews and ratings, video reviews, user opinions, most popular network hardware, wireless network buying guides, prices, ...

Resources last updated: 11/25/2015 11:17:39 PM