I took this sample from http://dotnet247.com/247reference/msgs/10/52267.aspx
Please refer this also
   
   
  ASP.NET Page
   
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" 
Inherits="_Default" %>
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
  <html xmlns="http://www.w3.org/1999/xhtml"; >
  <head runat="server">
  <title>Untitled Page</title>
  </head>
  <body>
  <form id="form1" runat="server">
  <div>
  <asp:DataList ID="DataList1" runat="server">
  <ItemTemplate>
  <%# DataBinder.Eval(Container.DataItem,"CategoryName") %>
  <asp:Repeater DataSource='<%# 
GetSubCategories(Container.DataItem("CategoryID")) %>' ID="Repeater1" 
runat="server">
  <ItemTemplate>
  <%# DataBinder.Eval(Container.DataItem,"ProductName") %>
  </ItemTemplate>
  </asp:Repeater>
  </ItemTemplate>
  </asp:DataList></div>
  </form>
  </body>
  </html>
   
   
  Codebehind
   
  using System;
  using System.Data;
  using System.Configuration;
  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.Data.SqlClient;
  public partial class _Default : System.Web.UI.Page 
  {
  protected void Page_Load(object sender, EventArgs e)
  {
  SqlConnection con = new 
SqlConnection("server=localhost;database=northwind;uid=sa;pwd=server");
  SqlDataAdapter adap = new SqlDataAdapter("select * from Categories", con);
  DataSet ds = new DataSet();
  adap.Fill(ds, "Categories");
  DataList1.DataSource = ds.Tables["Categories"].DefaultView;
  DataList1.DataBind();
  
  }
  public DataView GetSubCategories(int CategoryID)
  {
  SqlConnection con = new 
SqlConnection("server=localhost;database=northwind;uid=sa;pwd=server");
  SqlDataAdapter adap1 = new SqlDataAdapter("select top 2 * from Products where 
CategoryID=" + CategoryID,con);
  DataSet ds1 = new DataSet();
  adap1.Fill(ds1, "Products");
  return (ds1.Tables["Products"].DefaultView);
  }
  }
   
  When i execute this program the error is as follows 
   
  Error 1 'System.Web.UI.WebControls.DataListItem.DataItem' is a 'property' but 
is used like a 'method' c:\inetpub\wwwroot\ListingCategories\Default.aspx 15 



                        
---------------------------------
Yahoo! Shopping
 Find Great Deals on Holiday Gifts at Yahoo! Shopping 

[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/KIlPFB/vlQLAA/TtwFAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to