Hi,
ich versuche grade in meinem Projekt das VB.NET Beispiel über verschachtelte Repeater in C# zu realisieren. Jedoch treten bei meinem Programmcode immer der folgende Fehler auf:
Error PortalNavMenu.ascx(7): error CS0117: 'object' does not contain a definition for 'Rows'
Error 'object' does not contain a definition for 'Rows' PortalNavMenu.ascx
Ich verwende .NET 2.0 Beta 2 und Visual Studio 2005 Beta 2.
welcher auf die folgende Codestelle hindeutet:
<asp:Repeater id="rptChild" runat="server"
DataSource='<%# Container.DataItem.Rows.GetChildRows("relChild") %>' >
Was mache ich falsch? Im VB Beispiel scheint es zu funktionieren????
Poste mal den Kompletten Code, vielleicht liegt der Teufel ja im Detail.
Vielen Dank im voraus für die Hilfe.
Greets Azrael Masters
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="PortalNavMenu.ascx.cs" Inherits="PortalNavMenu" %>
<ul>
<asp:Repeater id="rptMaster" runat="server">
<ItemTemplate>
<b><%# DataBinder.Eval(Container.DataItem, "CatName")%>
</b><br>
<asp:Repeater id="rptChild" runat="server" DataSource='<%# Container.DataItem.Rows.GetChildRows("relChild") %>' >
<ItemTemplate>
<li>
<a href="?Feed=<%# Eval("FeedId") %>"><asp:Label ID="FeedNameLabel" runat="server" Text='<%# Eval("FeedName") %>'></asp:Label></a>
</li>
<%# DataBinder.Eval(Container.DataItem, "FeedName")%>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
</ul>
using System;
using System.Data;
using System.Data.Common;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Configuration;
public partial class PortalNavMenu : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
string CONNSTRING = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
DbProviderFactory provider = DbProviderFactories.GetFactory(ConfigurationManager.ConnectionStrings["ConnectionString"].ProviderName);
DbConnection connection = provider.CreateConnection();
DbDataAdapter adapter = provider.CreateDataAdapter();
connection.ConnectionString = CONNSTRING;
string SQL = "select * from NGP1_Portal_FeedCats";
DbCommand command = provider.CreateCommand();
command.CommandText = SQL;
command.Connection = connection;
DataSet ds = new DataSet();
adapter.SelectCommand = command;
adapter.Fill(ds,"NGP1_Portal_FeedCats");
string SQL2 = "select * from NGP1_Portal_Feeds";
DbCommand command2 = provider.CreateCommand();
command2.CommandText = SQL2;
command2.Connection = connection;
adapter.SelectCommand = command2;
adapter.Fill(ds, "NGP1_Portal_Feeds");
ds.Relations.Add("relChild", ds.Tables["NGP1_Portal_FeedCats"].Columns["CatId"], ds.Tables["NGP1_Portal_Feeds"].Columns["FeedCat"]);
rptMaster.DataSource = ds.Tables["NGP1_Portal_FeedCats"];
Page.DataBind();
connection.Close();
}
}
kommt schon, pls help me. ms machts doch genauso: http://support.microsoft.com/kb/326338/de wieso funzt meine c# version nicht mit Container.DataItem.Rows.GetChildRows ?
danke... Lösung gibts hier: http://asp-forum.de/topic.asp?TOPIC_ID=27498
Kann bitte geclosed werden.