I know that there is unlimited of forum-treads about solutions to nested repeater problems.
Still, I just can't get it to work.
I really hope that someone could guide me to the right solution for creating a nested repeater once and for all
Error:
"Object reference not set to an instance of an object."
Source Error:
"Line 14: Dim cmd2 As Data.SqlClient.SqlDataAdapter = New Data.SqlClient.SqlDataAdapter("SELECT * from tblRegions", cnn)
Line 15: cmd2.Fill(ds, "ID")
Line 16: ds.Relations.Add("myrelation", _
Line 17: ds.Tables("Links").Columns("ParentCategory"), _
Line 18: ds.Tables("tblRegions").Columns("ID"))"
My code:
test.aspx
<%... Page Language="VB" AutoEventWireup="false" MasterPageFile="~/MasterPage.master" CodeFile="test.aspx.vb" Inherits="test" %
<asp:Content ID="ContentTest" ContentPlaceHolderID="ContentMain" Runat="Server"
<asp:Repeater ID="parentRepeater" runat="server">
<ItemTemplate>
<b>
<%#DataBinder.Eval(Container.DataItem, "ID")%>
</b>
<br>
<asp:Repeater ID="childRepeater" runat="server" DataSource='<%# Container.DataItem.Row.GetChildRows("myrelation") %>'>
<ItemTemplate>
<%#Container.DataItem("ID")%>
<br>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater
</asp:Content
Test.aspx.vb
Public Class test
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cnn As Data.SqlClient.SqlConnection = New Data.SqlClient.SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings("GetCategoriesConnectionString").ConnectionString)
cnn.Open()
Dim cmd1 As Data.SqlClient.SqlDataAdapter = New Data.SqlClient.SqlDataAdapter("SELECT * from Links", cnn)
Dim ds As New Data.DataSet()
cmd1.Fill(ds, "ParentCategory")
Dim cmd2 As Data.SqlClient.SqlDataAdapter = New Data.SqlClient.SqlDataAdapter("SELECT * from tblRegions", cnn)
cmd2.Fill(ds, "ID")
ds.Relations.Add("myrelation", _
ds.Tables("Links").Columns("ParentCategory"), _
ds.Tables("tblRegions").Columns("ID"))
parentRepeater.DataSource = ds.Tables("Links")
parentRepeater.DataSource = ds.Tables("Links")
Page.DataBind()
cnn.Close()
End Sub
End Class
I am struggling with something that should be fairly easy, but I think I am too flustered now to see...
By thekeggerman
Hello all,can anyone tell me the difference between the two connections OleDBConnection and the new ...
By mostafaadel
Does the Dispose() method of OleDbConnection automatically call OleDbConnection.ReleaseObjectPool()....
By anonymous
This code does not work it fails on Execute.::CoInitialize(NULL);_ConnectionPtr m_Connection("ADODB....
By mayankjha
Hi NewsGroup, Hope this is the right news group for this. Programming data access code in C#, .NET F...
By anonymous, 3 Comments
So I have a datagrid and it is updatable, however, I have another form on the page that has two boxe...
By cattrah, 1 Comments
my css inside in datagrid. It won't work, I don't know why.<HTML><body MS_POSITIONING="GridLay...
By hong_ma, 10 Comments
I have an editcommandcolumn of links that take on internal css attributes that are delcared in the h...
By cusoxty, 14 Comments
I am struggling with something that should be fairly easy, but I think I am too flustered now to see...
By thekeggerman, 4 Comments
Hi,Woppie:
ds.Relations.Add("myrelation", _
Line 17: ds.Tables("Links").Columns("ParentCategory"), _
Line 18: ds.Tables("tblRegions").Columns("ID"))"
I do not see the datatable Links and tblRegions in your ds above.
According to the following code you have, i suppose the name of the datatable is ParentCategory and ID.
cmd1.Fill(ds, "ParentCategory")
cmd2.Fill(ds, "ID")
rexlin | Sun, 06 Jan 2008 00:26:00 GMT |