Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
| Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 24th, 2006, 10:29 AM
Authorized User
 
Join Date: Apr 2006
Location: , , .
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default hyperlink in nested datalist calling a repeater

Here the situation is like this.
On my page I am listing the name of campuses grouped my state.Then when the user clicks on the campus , the listing of rental locations under that particular campus pops up in the repeater.
So it looks like this-
Arizona
-campus A
-campus B
California
-campus c
-campus d

If the user clicks on -campus A ,then all the rental locations under campus A will show in a repeater.

<asp:DataList id="DataList" style="Z-INDEX: 101; LEFT: 48px; POSITION: absolute; TOP: 56px" runat="server">
<SelectedItemStyle BackColor="#FFFFC0"></SelectedItemStyle>
<ItemTemplate>
<h2><%# DataBinder.Eval(Container,"DataItem.statefull")%></h2>
<asp:DataList id="DataList1" DataSource='<%# Showcampus(DataBinder.Eval(Container,"DataItem.sta teid"))%>' Runat="server">
                        <ItemTemplate>[list]
<li>
<asp:LinkButton ID="Linkbutton2" Runat="server" Text='<%# DataBinder.Eval(Container,"DataItem.name")%>'>
</asp:LinkButton>
</li>
</ul>
</ItemTemplate>
</asp:DataList>
</ItemTemplate>
</asp:DataList>
<DIV style="Z-INDEX: 102; LEFT: 408px; WIDTH: 272px; POSITION: absolute; TOP: 56px; HEIGHT: 224px" ms_positioning="FlowLayout">
<asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
<li>
<%# DataBinder.Eval(Container, "DataItem.facility_center_name")%>
</li>
</ItemTemplate>
<SeparatorTemplate>

</SeparatorTemplate>
</asp:Repeater></DIV>

the code behind--
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
sqlDataAdapter1.Fill(dataSet1);
sqlDataAdapter2.Fill(dataSet1);
sqlDataAdapter3.Fill(dataSet1);
DataList.DataSource = dataSet1;
DataList.DataMember = "tbl_state";
DataList1.DataSource = dataSet1;
DataList1.DataKeyField ="campus_id";
DataList.DataBind();
DataList1.DataBind();

}
public DataView Showcampus(object stateid)
{
string strFilter = "stateid=" + stateid;
DataView dvcampus = new DataView(
dataSet1.Tables[ "tbl_location" ],
strFilter,
"name",
DataViewRowState.CurrentRows);
return dvcampus;
}
private void DataList1_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
{
DataList1.SelectedIndex = e.Item.ItemIndex;
int intPrimaryKey = (int)DataList1.DataKeys[e.Item.ItemIndex];
sqlDataAdapter3.SelectCommand.Parameters["@campus_id"].Value=intPrimaryKey;
sqlDataAdapter3.Fill(dataSet1);
Repeater1.DataSource = dataSet1;
Repeater1.DataBind();
}

 
Old May 25th, 2006, 08:17 AM
Friend of Wrox
 
Join Date: May 2006
Location: Delhi, Delhi, India.
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Almost same thing is tried to be achieved mentioned in forum titled " Drill down datagrid in C#.net ". I'll suggest to set id property of first datalist to any other variable name as DataList is iteself a class name so always avoid to use name of any identifier as System defined class name, Keywords, reserved words etc.

Bijgupt




Similar Threads
Thread Thread Starter Forum Replies Last Post
nested repeater ramonjor ASP.NET 2.0 Basics 0 July 31st, 2007 04:18 AM
FindControl in nested repeater chrisk_47 .NET Framework 2.0 0 February 6th, 2007 10:45 PM
nested repeater david_ste ASP.NET 2.0 Professional 0 August 24th, 2006 09:52 AM
hyperlink in nested datalist debjanib ASP.NET 1.0 and 1.1 Professional 3 June 5th, 2006 02:17 PM
Hyperlink in repeater control? johno ASP.NET 2.0 Professional 1 April 19th, 2006 05:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.