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
What am I doing wrong here? I am trying to get the PrimaryKey value for a just inserted record.prot...
By zoltac007
There is checkBox in Repeater, that inside GridView's column.Into Repeater's ItemDataBound I...
By fixer
HiHas somebody a Visual Basic 6.0 Sample Code which can call the following example procedure.test_pa...
By koebm1
Hi, By using Data Access Application Block, I am getting cursors from the Oracle stored proced...
By kalkumar
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 am struggling with something that should be fairly easy, but I think I am too flustered now to see...
By thekeggerman, 4 Comments
Hello guys, I need some advice in this because this is my first time using security logins and sever...
By dawel, 1 Comments
Hello -I'm using the Repeater rather than the DataGrid for a number of reasons in my particular appl...
By billywilly, 3 Comments
I have a repeater and it has an update button and then a quantity text box and then some databound l...
By torontovb, 10 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 |