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();
}
|