nesting repeater in datalist (slider menu)

Posted on January 3, 2009. Filed under: Asp.net |

put in head tag

<script src=”js/jquery-1.2.6.min.js” type=”text/javascript”></script>
<script language=javascript>
function show(id)
{
var tc=document.getElementById(“tot”).value;
for(var i=1;i<=tc;i++)
{
if(“div”+i==id)
{

$(“#div”+i).show(“slow”);
}
else
$(“#div”+i).hide(“slow”);
}
}
// window.onload=show(‘div1′)
</script

in body tag

<div>
<asp:HiddenField ID=”tot” runat=server />
<asp:DataList ID=”dl_cat” runat=server >
<ItemTemplate>
<div style=”color:white;font-size:13px;font-weight:bold;cursor:pointer;width:250px;height:20px;background-color:Gray;padding-bottom:3px;padding-top:3px;padding-left:5px” onclick=”show(‘div<%#Container.ItemIndex+1%>’)” >
<%#Eval(“categoryname”) %>
</div>
<div id=’div<%#Container.ItemIndex+1%>’ style=”background-color:Yellow;display:none”>
<asp:Repeater ID=”rp_subcat” DataSource=’<%#DataBinder.Eval(Container, “DataItem.InnerVal”) %>’ runat=server >
<ItemTemplate>
<span style=”padding-left:10px”><%#Eval(“productname”) %></span><br />
</ItemTemplate>
</asp:Repeater>
</div>
</ItemTemplate>
</asp:DataList>
</div>

//in code file

protected void Page_Load(object sender, EventArgs e)
{

DataAccessLayer dl = new DataAccessLayer();
DataSet ds = new DataSet();
dl.RunProcedure(“cate_product”, ref ds);
ds.Relations.Add(“InnerVal”, ds.Tables[0].Columns["categoryid"], ds.Tables[1].Columns["categoryid"]);
tot.Value = ds.Tables[0].Rows.Count.ToString();
dl_cat.DataSource = ds.Tables[0];
dl_cat.DataBind();

}

//procedure name

CREATE PROCEDURE [dbo].[cate_product]

AS

select c.categoryid,c.categoryname,p.productid,p.productname into #tampĀ  from categories c

inner join products p on c.categoryid=p.categoryid

select distinct categoryid,categoryname from #tamp

select categoryid,productname from #tamp

drop table #tamp
GO

Make a Comment

Make a Comment: ( None so far )

blockquote and a tags work here.

    About

    Hi,I am Suresh Sharma from Gorakhpur , UP, India.I have work on .net technology from 2 years. Key skills-Asp.net 2.0,3.5, Sql 2005,2000. Ajax.net 1.1,C#.net

    RSS

    Subscribe Via RSS

    • Subscribe with Bloglines
    • Add your feed to Newsburst from CNET News.com
    • Subscribe in Google Reader
    • Add to My Yahoo!
    • Subscribe in NewsGator Online
    • The latest comments to all posts in RSS
    • Subscribe in Rojo

    Meta

Liked it here?
Why not try sites on the blogroll...