rss2
asked on
Inner Repeater not displaying data
I have a page with an outer Repeater and an inner Repeater.
The behind code is in VB.NET.
The outer Repeater is executing just fine, but the inner repeater does not display any data.
I have confirmed that there is data there for it to display.
Here is my code:
aspx.vb:
Protected Sub LoadData()
Dim conn As New SqlConnection
Dim cmd As New SqlCommand
Dim connstring As String
Dim da As New SqlDataAdapter
Dim dt As New DataTable
Dim ds As New Data.DataSet
connstring = Connector.ConnectStringBui ld
conn.ConnectionString = connstring
cmd.Connection = conn
cmd.CommandText = "ACT_GET_COLLECTION_DETAIL S"
cmd.CommandType = CommandType.StoredProcedur e
cmd.Parameters.Add("@SERVI CE_ID", SqlDbType.Int).Value = SetVars.Service_ID
cmd.Parameters.Add("@LOGON _NAME", SqlDbType.VarChar).Value = SetVars.UserName
cmd.Parameters.Add("@INDIC ATOR", SqlDbType.VarChar).Value = SetVars.Indicator
conn.Open()
da.SelectCommand = cmd
da.Fill(ds, "ACT_COLLECTION")
conn.Close()
cmd.CommandText = "ACT_GET_FUNCTION_SERVICE_ DETAILS"
cmd.CommandType = CommandType.StoredProcedur e
cmd.Parameters.Clear()
cmd.Parameters.Add("@GROUP _NAME", SqlDbType.VarChar).Value = SetVars.GroupName
cmd.Parameters.Add("@SERVI CE_ID", SqlDbType.Int).Value = SetVars.Service_ID
cmd.Parameters.Add("@OBJEC T_NAME", SqlDbType.VarChar).Value = "COLLECTION"
'cmd.Parameters.Add("@COLL ECTION_ID" , SqlDbType.Int).Value = 7
conn.Open()
Dim da1 As New SqlDataAdapter
da1.SelectCommand = cmd
da1.Fill(ds, "ACT_PERMISSION")
ds.Relations.Add("COLLECTI ON_ID_Rela tion", ds.Tables(0).Columns("COLL ECTION_ID" ), ds.Tables(1).Columns("COLL ECTION_ID" ))
Me.ParentRepeater.DataSour ce = ds.Tables(0)
Me.ParentRepeater.DataBind ()
conn.Close()
End Sub
asp:
<asp:Repeater ID="ParentRepeater" runat="server">
<HeaderTemplate>
<table style="LEFT: 178px; WIDTH: 980px; POSITION: absolute; TOP: 195px" id="DataTable">
<tr>
<th class="intraContent"><b>Ac tion</b></ th>
<th class="intraContent"><b>Co llection Name</b></th>
<th class="intraContent"><b>Cu rrent Version</b></th>
<th class="intraContent"><b>De scription< /b></th>
<th class="intraContent"><b>Li fecycle </b></th>
<th class="intraContent"><b>En vironment< /b></th>
<th class="intraContent"><b>Re leased On</b></th>
<th class="intraContent"><b>Pu blished On </b></th>
<th class="intraContent"><b>Pa ckages</b> </th>
<th class="intraContent"><b>Qu eries</b>< /th>
<th class="intraContent"><b>Ho sts</b></t h>
</tr>
</headertemplate>
<ItemTemplate>
<asp:repeater ID="InnerRepeater" runat="Server">
<ItemTemplate>
<tr>
<td class="intraContent">
<%#DataBinder.Eval(Contain er.DataIte m, "COLLECTION_ID")%>
</td>
</ItemTemplate>
</asp:repeater>
<td class="intraContent" onmouseover="this.classNam e='intraCo ntentHover '" onmouseout="this.className ='intraCon tent'"><%# DataBinder .Eval(Cont ainer.Data Item, "COLLECTION_NAME")%></td>
<td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.classNam e='intraCo ntentHover '" onmouseout="this.className ='intraCon tent'"><%# DataBinder .Eval(Cont ainer.Data Item, "Current_Version")%></td>
<td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.classNam e='intraCo ntentHover '" onmouseout="this.className ='intraCon tent'"><%# DataBinder .Eval(Cont ainer.Data Item, "DESCRIPTION")%></td>
<td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.classNam e='intraCo ntentHover '" onmouseout="this.className ='intraCon tent'"><%# DataBinder .Eval(Cont ainer.Data Item, "LIFECYCLE")%></td>
<td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.classNam e='intraCo ntentHover '" onmouseout="this.className ='intraCon tent'"><%# DataBinder .Eval(Cont ainer.Data Item, "ENVIRONMENT")%></td>
<td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.classNam e='intraCo ntentHover '" onmouseout="this.className ='intraCon tent'"><% Response.Write("????")%></ td>
<td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.classNam e='intraCo ntentHover '" onmouseout="this.className ='intraCon tent'"><%# DataBinder .Eval(Cont ainer.Data Item, "PUBLISHED_ON")%></td>
<td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.classNam e='intraCo ntentHover '" onmouseout="this.className ='intraCon tent'"><as p:linkbutt on runat="server" ID="linkButtonc1" CssClass="lnkbutton" CommandName="PACKAGES_COUN T" CommandArgument='<%# DataBinder.Eval(Container. DataItem," COLLECTION _ID") %>'><%#DataBinder.Eval(Con tainer.Dat aItem, "PACKAGES")%></asp:linkbut ton></td>
<td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.classNam e='intraCo ntentHover '" onmouseout="this.className ='intraCon tent'"><as p:linkbutt on runat="server" ID="linkButtonc2" CssClass="lnkbutton" CommandName="QUERIES_COUNT " CommandArgument='<%# DataBinder.Eval(Container. DataItem," COLLECTION _ID") %>'><%#DataBinder.Eval(Con tainer.Dat aItem, "QUERIES")%></asp:linkbutt on></td>
<td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.classNam e='intraCo ntentHover '" onmouseout="this.className ='intraCon tent'"><as p:linkbutt on runat="server" ID="linkButtonc3" CssClass="lnkbutton" CommandName="HOSTS_COUNT" CommandArgument='<%# DataBinder.Eval(Container. DataItem," COLLECTION _ID") %>'><%#DataBinder.Eval(Con tainer.Dat aItem, "HOSTS") %></asp:linkbutton></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
When I specify a datasource for the inner Repeater I get errors.
Anyway, what I get with the above code is data for the outer Repeater, but no data for the inner Repeater.
Any ideas?? PLease help!
Thank you!
The behind code is in VB.NET.
The outer Repeater is executing just fine, but the inner repeater does not display any data.
I have confirmed that there is data there for it to display.
Here is my code:
aspx.vb:
Protected Sub LoadData()
Dim conn As New SqlConnection
Dim cmd As New SqlCommand
Dim connstring As String
Dim da As New SqlDataAdapter
Dim dt As New DataTable
Dim ds As New Data.DataSet
connstring = Connector.ConnectStringBui
conn.ConnectionString = connstring
cmd.Connection = conn
cmd.CommandText = "ACT_GET_COLLECTION_DETAIL
cmd.CommandType = CommandType.StoredProcedur
cmd.Parameters.Add("@SERVI
cmd.Parameters.Add("@LOGON
cmd.Parameters.Add("@INDIC
conn.Open()
da.SelectCommand = cmd
da.Fill(ds, "ACT_COLLECTION")
conn.Close()
cmd.CommandText = "ACT_GET_FUNCTION_SERVICE_
cmd.CommandType = CommandType.StoredProcedur
cmd.Parameters.Clear()
cmd.Parameters.Add("@GROUP
cmd.Parameters.Add("@SERVI
cmd.Parameters.Add("@OBJEC
'cmd.Parameters.Add("@COLL
conn.Open()
Dim da1 As New SqlDataAdapter
da1.SelectCommand = cmd
da1.Fill(ds, "ACT_PERMISSION")
ds.Relations.Add("COLLECTI
Me.ParentRepeater.DataSour
Me.ParentRepeater.DataBind
conn.Close()
End Sub
asp:
<asp:Repeater ID="ParentRepeater" runat="server">
<HeaderTemplate>
<table style="LEFT: 178px; WIDTH: 980px; POSITION: absolute; TOP: 195px" id="DataTable">
<tr>
<th class="intraContent"><b>Ac
<th class="intraContent"><b>Co
<th class="intraContent"><b>Cu
<th class="intraContent"><b>De
<th class="intraContent"><b>Li
<th class="intraContent"><b>En
<th class="intraContent"><b>Re
<th class="intraContent"><b>Pu
<th class="intraContent"><b>Pa
<th class="intraContent"><b>Qu
<th class="intraContent"><b>Ho
</tr>
</headertemplate>
<ItemTemplate>
<asp:repeater ID="InnerRepeater" runat="Server">
<ItemTemplate>
<tr>
<td class="intraContent">
<%#DataBinder.Eval(Contain
</td>
</ItemTemplate>
</asp:repeater>
<td class="intraContent" onmouseover="this.classNam
<td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.classNam
<td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.classNam
<td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.classNam
<td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.classNam
<td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.classNam
<td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.classNam
<td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.classNam
<td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.classNam
<td class="intraContent" align="center" style="border-bottom: 2px solid #D3D3D3" onmouseover="this.classNam
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
When I specify a datasource for the inner Repeater I get errors.
Anyway, what I get with the above code is data for the outer Repeater, but no data for the inner Repeater.
Any ideas?? PLease help!
Thank you!
Well, you need to specify a datasource for the inner repeater as there is nothing for it to display without a datasource. What error do you get?
generally, when i nest repeaters i use a separate function that returns the data i want for the nested repeater. so i'd have something like
Sub Repeater1Load()
get the data
bind to repeater1
End Sub
Function NestedData(var1, var2) As DataTable
return the data with those variables
End Function
<asp:Repeater id="repeater1" ...>
<itemtemplate>
<asp:Repeater id="repeater2" datasource='<%# NestedData(Container.DataI tem("item1 "), Container.DataItem("item2" )) %>'>
Sub Repeater1Load()
get the data
bind to repeater1
End Sub
Function NestedData(var1, var2) As DataTable
return the data with those variables
End Function
<asp:Repeater id="repeater1" ...>
<itemtemplate>
<asp:Repeater id="repeater2" datasource='<%# NestedData(Container.DataI
ASKER
If done your way, where do you make the relation between the two tables?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
When I do it this way, and I reference the dropdownlist within function Children, I get a blue squiggly line underneath it with the error "Name 'ActionDropDownList' is not declared.'
(I gave the dropdownlist the id ActionDropDownList)
why can't I see <asp:Dropdownlist> from wtihin the repeater? If I take it outside the context of the repeater I can see it in my code but not when it's within it.
(I gave the dropdownlist the id ActionDropDownList)
why can't I see <asp:Dropdownlist> from wtihin the repeater? If I take it outside the context of the repeater I can see it in my code but not when it's within it.
ASKER
OMG this has been such a pain to get working.
Finally it's compiling but such an incredible amount of pain I've gone through to get this working.
Okay I think I'm coming down the home stretch now..this question should be easy for you. I'm just so exhausted I can't think straight.
Here's a fragment from my aspx page:
<td class="intraContent">
<asp:DropDownList ID="ActionDropDownList" runat="Server" AutoPostBack="true" OnDataBinding="DropDownLis tSelect">
</asp:DropDownList>
<asp:Label ID="lblStatus" runat="Server"></asp:Label >
<asp:Repeater ID="InnerRepeater" runat="Server">
<ItemTemplate>
</ItemTemplate>
</asp:Repeater>
and in the code behind file, I have DropDownListSelect which is called when the dropdownlist is bound to data.
Protected Sub DropdownListSelect(ByVal sender As Object, ByVal e As System.EventArgs)
Dim conn As New SqlConnection
Dim cmd As New SqlCommand
Dim connstring As String
Dim da As New SqlDataAdapter
Dim dt As New DataTable
Dim ds As New Data.DataSet
'Dim theDropDownList As New DropDownList
'theDropDownList = CType(FindControl("ActionD ropDownLis t"), DropDownList)
Dim childa As New SqlDataAdapter
connstring = Connector.ConnectStringBui ld
conn.ConnectionString = connstring
cmd.Connection = conn
cmd.CommandText = "ACT_GET_FUNCTION_SERVICE_ DETAILS"
cmd.CommandType = CommandType.StoredProcedur e
cmd.Parameters.Add("@GROUP _NAME", SqlDbType.VarChar).Value = SetVars.GroupName
cmd.Parameters.Add("@SERVI CE_ID", SqlDbType.Int).Value = SetVars.Service_ID
cmd.Parameters.Add("@OBJEC T_NAME", SqlDbType.VarChar).Value = "COLLECTION"
conn.Open()
childa.SelectCommand = cmd
'childa.Fill(dt)
childa.Fill(ds)
Dim theDropDownList As New DropDownList
'theDropDownList = CType(e.Item.FindControl(" ActionDrop DownList") , DropDownList)
theDropDownList.DataSource = ds
theDropDownList.DataBind()
End Sub
When I run the page, nothing is in the drop down list. What the heck am I doing wrong?
Thanks,
rss2
Finally it's compiling but such an incredible amount of pain I've gone through to get this working.
Okay I think I'm coming down the home stretch now..this question should be easy for you. I'm just so exhausted I can't think straight.
Here's a fragment from my aspx page:
<td class="intraContent">
<asp:DropDownList ID="ActionDropDownList" runat="Server" AutoPostBack="true" OnDataBinding="DropDownLis
</asp:DropDownList>
<asp:Label ID="lblStatus" runat="Server"></asp:Label
<asp:Repeater ID="InnerRepeater" runat="Server">
<ItemTemplate>
</ItemTemplate>
</asp:Repeater>
and in the code behind file, I have DropDownListSelect which is called when the dropdownlist is bound to data.
Protected Sub DropdownListSelect(ByVal sender As Object, ByVal e As System.EventArgs)
Dim conn As New SqlConnection
Dim cmd As New SqlCommand
Dim connstring As String
Dim da As New SqlDataAdapter
Dim dt As New DataTable
Dim ds As New Data.DataSet
'Dim theDropDownList As New DropDownList
'theDropDownList = CType(FindControl("ActionD
Dim childa As New SqlDataAdapter
connstring = Connector.ConnectStringBui
conn.ConnectionString = connstring
cmd.Connection = conn
cmd.CommandText = "ACT_GET_FUNCTION_SERVICE_
cmd.CommandType = CommandType.StoredProcedur
cmd.Parameters.Add("@GROUP
cmd.Parameters.Add("@SERVI
cmd.Parameters.Add("@OBJEC
conn.Open()
childa.SelectCommand = cmd
'childa.Fill(dt)
childa.Fill(ds)
Dim theDropDownList As New DropDownList
'theDropDownList = CType(e.Item.FindControl("
theDropDownList.DataSource
theDropDownList.DataBind()
End Sub
When I run the page, nothing is in the drop down list. What the heck am I doing wrong?
Thanks,
rss2
ASKER
What do I need to do to actually get the data from the dataset ds inside the dropdownlist?
This is killing me I just can't figure it out!
This is killing me I just can't figure it out!
ASKER
Is anybody out there??
For the parent repeater, I have
Protected Sub ParentRepeater_ItemDataBou nd(ByVal sender As Object, ByVal e As RepeaterItemEventArgs)
Dim ddl As New DropDownList
ddl = CType(e.Item.FindControl(" DropDownLi stinside") , DropDownList)
ddl.DataSource = ds
ddl.DataBind()
..but on the line that says:
CType(e.Item.FindControl(" DropDownLi stinside") ,DropDownL ist)
the ddl object that I instantiate goes to "Nothing" after that line.
So I'm assuming it's not finding the correct control.
How do I get it to find the correct control??? This is maddening.
For the parent repeater, I have
Protected Sub ParentRepeater_ItemDataBou
Dim ddl As New DropDownList
ddl = CType(e.Item.FindControl("
ddl.DataSource = ds
ddl.DataBind()
..but on the line that says:
CType(e.Item.FindControl("
the ddl object that I instantiate goes to "Nothing" after that line.
So I'm assuming it's not finding the correct control.
How do I get it to find the correct control??? This is maddening.