Hi all,
   
  Thanks a lot for posting replies to my queries. And at last i achieved what i 
wanted and here is the code for that.
   
  Now i would like to a step further by adding a more text after the end of 
displaying two subcategories names (See the output at the bottom of this page) 
Please help me achieving that.
   
  The present output is 
   
  Beverages 
Chai , Chang 
   
  The desired output should be
   
  Beverages 
Chai , Chang , more
   
  Please help
   
   
   
  ASPX 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" RepeatColumns="3" 
RepeatDirection="Horizontal" Width="100%" BackColor="White" 
BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" 
GridLines="Horizontal">
  <HeaderTemplate>
  Categories
  </HeaderTemplate>
  <ItemTemplate>
  <a href="categories.aspx?CategoryID=<%# 
DataBinder.Eval(Container.DataItem,"CategoryID") %>">
  <%# DataBinder.Eval(Container.DataItem,"CategoryName") %>
  </a>
  <br />
  <asp:Repeater DataSource='<%# 
GetSubCategories(DataBinder.Eval(Container.DataItem,"CategoryID")) %>' 
ID="Repeater1" runat="server">
  <ItemTemplate>
  <a href="categories.aspx?CategoryID=<%# 
DataBinder.Eval(Container.DataItem,"CategoryID") %>">
  <%# DataBinder.Eval(Container.DataItem,"ProductName") %>
  </a>
  </ItemTemplate>
  <SeparatorTemplate>,
  </SeparatorTemplate>
  </asp:Repeater>
  </ItemTemplate>
  <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
  <SelectedItemStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
  <AlternatingItemStyle BackColor="#F7F7F7" />
  <ItemStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
  <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
  </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(object CatID)
  {
  int CategoryID = (int)CatID;
  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);
  }
  }
   
   
  Output is 
   
          Categories     Beverages 
Chai , Chang   Condiments 
Aniseed Syrup , Chef Anton's Cajun Seasoning   Confections 
Pavlova , Teatime Chocolate Biscuits     Dairy Products 
Queso Cabrales , Queso Manchego La Pastora   Grains/Cereals 
Gustaf's Knäckebröd , Tunnbröd   Meat/Poultry 
Mishi Kobe Niku , Alice Mutton     Produce 
Uncle Bob's Organic Dried Pears , Tofu   Seafood 
Ikura , Konbu 


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

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



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/I258zB/QnQLAA/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