Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional 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:42 AM
Authorized User
 
Join Date: Apr 2006
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default hyperlink in nested datalist

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.
In a seperate file I can show the campuses grouped by state, and it is running. In another file if I just click on campus it shows the the rental location. But If I combine all three of them together it gives me an error. PLease help-

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 24th, 2006, 02:14 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

What's the error?

 
Old May 25th, 2006, 09:12 AM
Authorized User
 
Join Date: Apr 2006
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The error says "Object reference not set to an instance of an object" Problem with DataList1

 
Old June 5th, 2006, 02:17 PM
jgd jgd is offline
Registered User
 
Join Date: May 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jgd
Default

i'm having this same problem.... except in mine i've got everything working... then I even am printing out my sql to the screen, which uses a textbox in the edititemtemplate of a nested datalist... anyone got any suggestions?

Joseph
wdweb.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
DataList with HyperLink Ioulia ASP.NET 1.x and 2.0 Application Design 2 May 7th, 2011 12:41 PM
Nested datalist arijoy ASP.NET 1.0 and 1.1 Professional 0 December 6th, 2006 01:23 PM
hyperlink in nested datalist calling a repeater debjanib C# 1 May 25th, 2006 08:17 AM
Using Javascript in Nested Datalist savan_thakkar ASP.NET 1.0 and 1.1 Professional 0 March 21st, 2006 05:54 PM
Nested DataList Problem orcities C# 0 July 12th, 2004 01:40 PM





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