.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Display a nested child ListView on PostBack while using DataPager on parent ListView

Posted By:      Posted Date: August 26, 2010    Points: 0   Category :ASP.Net

Hello ASP.NET community,

I am having trouble finding how to solve the following issue :

I am using nested listviews to display Sales and Sales details.

The main ListView displays General Information about Sales and the child ListView displays the detailed information about one sale. the child listview is shown only when the user clicks on a link (see included code, DataBind is made on PageLoad) :

ASPX Markup Code :

<asp:listview id="lvSales" runat="server" onitemdatabound="lvSales_ItemDataBound">
<table cellspacing="0" border="1" width="250" style="border-collapse:collapse;">
<tr runat="server" id="headerRow">
<th scope="col" style="width:30px;"></th>
<th scope="col">SaleNumber</th>
<tr id="itemPlaceHolder" runat="server" enableviewstate="true"/>
<tr id="row" runat="server">
<td style="text-align:center;"><asp:button id="btnShowHideDetails" runat="server" oncommand=&qu

View Complete Post

More Related Resource Links

Nested ListView: Parent listview item auto selection on child ListViewitem select


how can i auto select paraten listview item on selecting child listview item?

ListView ItemContainerStyle="{StaticResource myStyle}" Name="lv_list" Margin="5" HorizontalContentAlignment="Stretch">

Exception caused by DataPager.SetPageProperties() on ListView (postback error)

 Hi, I have a issue with drives me crazy! I'm using the DataPager method SetPageProperties() to restore the current page in my listview after I navigated into a page related to a listview item. (I persist the current page in the session state) I display 10 items at a time, and there are 10 pages. Everything works perfectly for the first 100 items, .... but after I go beyond (to display pages 11 to 20), if I call SetPageProperties() to restore the proper "current" page, I cannot submit anymore anything without getting the following exception: An error has occurred because a control with id 'ctl00$ctl00$ContentPlaceHolder$ContentPlaceHolder1$m_ListViewSearchItems$lvProductsPager$ctl00$ctl10' could not be located or a different control is assigned to the same ID after postback. If the ID is not assigned, explicitly set the ID property of controls that raise postback events to avoid this error. The exception refers to the DataPager sub-controls which are not rendered the same way for first pages (1 - 10) than (11 - 21); Is that because it expect then a "previous page" button? I don't quite know what to think about it. Does anyone have a clue?

Using ASP.NET 3.5's ListView and DataPager Controls: Displaying Data with the ListView

Prior to ASP.NET 3.5, developers who needed to display a set of records could choose between the GridView, DataList, and Repeater controls. The GridView provides rich data features, but has a very boxy layout; the DataList and Repeater allow for a more flexible layout, but lack the "point and click" data features found in the GridView, DetailsView, and FormView controls. The ListView bridges the gap between layout flexibility and built-in data features.

This article, the first in a series of articles on the ListView and DataPager controls, looks at the ListView's many available templates and illustrates how to display data. Read on to learn more!

ListView DataPager with SQL-Statements that already return only paged data.



As far as I understand the ListView-Control and the DataPager-Control, they work like this: The ListView gets its datarows from its data source, then the DataPager causes the ListView to display only a subset of those rows.

So what, when I want to use custom databinding for the ListView, that *already* gets the certain subset from SQL-Server (for better performance). Can I and how can I use the DataPager then?

Thanx, S.

Nested listview fk-problem with insert



My problem is this, i have a nested listview that works fine but if i need to do an insert and the nested listview dont have retrived any values (that is no posts created) i cant get hold of the fk that i need. If i put a hiddenfield in the parents listview with the fk how can i find it in codebehind when i do an insert? 



Microsoft ListView Control 6.0 cannot correctly display multibyte characters when running on a 64 bi

With all the regional settings set to Russian and the OS being Russion the ListView Control 6.0 does not display the column headers correctly on the Windows Server 2008 64 bit OS. If we switch to using Microsoft ListView Control, version 5 the columns (text strings) are displayed correctly. I am concerned that using an earlier version is going to cause problems. Is there a better solution other than using version 5? Thanks!

Help Getting ListView To Display Data

I have years of Java experience but am new to .NET development.  I am currently working with C# and Microsoft Visual C# 2008.  Everything has been going well accept for one snag.  I can't get a ListView to display anything.  I've now spent hours on it and it seems I just don't get it.  Below is a sample program of my problem.  I am constructing the ListView in the Form constructor.  It's supposed to have 2 groups with 2 items, but when I run the program, the ListView is empty.  I've played around with trying different view types, but to no avail.  I've reduced it to the bare minimum and still don't get it.  What am I missing? using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace DemoFormApp { public partial class Form1 : Form { public Form1() { InitializeComponent(); ListViewGroup group1 = new ListViewGroup("Group One"); ListViewGroup group2 = new ListViewGroup("Group Two"); ListViewItem item1 = new ListViewItem("ABC"); ListViewItem item2 = new ListViewItem("CD"); group1.Items.Add(item1); group2.Items.Add(item2); listView1.Groups.Add(group1); listView1.Groups.Add(group

Display the item in the ComboBox inside the ListView(GridView)

I have the below code used in binding the values to the ComboBox in GridView(ListView), please help me < ListView Margin="480,51,6,14" Name="grid1" ItemsSource="{Binding UserDetail}" IsSynchronizedWithCurrentItem="True" Width="389" Grid.Column="1" > <ListView.View> <GridView> <GridViewColumn Header="UserName" Width="120" DisplayMemberBinding="{Binding Path=WindowsUser}"/> <GridViewColumn Header="Role" Width="140"> <GridViewColumn.CellTemplate> <DataTemplate> <ComboBox Name="Rolecombo" Width="120" ItemsSource="{Binding Path=UserDetail}" SelectedValue="{Binding PFR_Tbl_Role.Role}"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn Header="Active" x:Name="column" Width="100"> <GridViewColumn.CellTemplate> <DataTemplate> <Grid Width="{Binding ElementName=column,Path=Width}"> <CheckBox IsChecked="{Binding Active}" HorizontalAlignment="Center" /> </Grid> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView>  </ListView.View> </ListView>

Customizing the display for a ListView Web Part

I want to customize the display of a ListView Web Part. I tried following this [http://msdn.microsoft.com/en-us/library/ff604024.aspx] article, but I'm not having any success. Has anyone done something like this before? I need a very simple and basic view from which I can build upon. Like displaying only the Title field of a list without the column headers and other stuff. Thanks!

Getting innermost ListView of triple nested ListViews

Hello, I am having a problem with finding the innermost ListView of a triple nested ListView. The middle ListView has a LinkButton whose event is handled by the outermost's ItemCommand. In the ItemCommand I want to find the third, innermost ListView and set its datasource. How can I find it?

Display ListView inside ListViewItem???

Hi,   I was first using a tree view in order to display a two level hierarchical structure, however this was too slow (tree was taking up to 10 sec to display 3000 items). I believe that a listview will improve this performance. Is it possible to have a listview inside the listviewitem? So far I have this, the first level is being displayed, but no the second level Please help!! <ListBox x:Name="lstBoxHitList" Padding="5" Margin="1" ItemsSource="{x:Static local:Window1.SearchJobsList}" DockPanel.Dock="Bottom" MouseDoubleClick="tvHitList_MouseDoubleClick" TreeViewItem.Selected="tvHitList_Selected" ScrollViewer.HorizontalScrollBarVisibility="Disabled" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> <ListBox.Resources> <Style TargetType="ListBox" x:Key="ListBoxControlStyle" BasedOn="{StaticResource {x:Type ListBox}}"> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Items.Count}" Value="0"> <Setter Property="Template"> <Setter.Value> <ControlTemplate>

ListView with DataPager

Hi, i use a ListView with DataPager but fail when change page in the DataPager because does nothing. Producto losProductos = new BLL.Producto(); ListView1.DataSource = losProductos.TraerTodos(); //List<Producto> ListView1.DataBind();   <asp:ListView ID="ListView1" runat="server"> <LayoutTemplate> <ul class="ulproduct"> <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder> </ul> </LayoutTemplate> <ItemTemplate> <li> <table width="100%"> <tr> <td rowspan="3" class="style1"> <img class="img" src='<%# string.Format("/SirPet.com/img/productos/{0}.jpg", Eval("Codigo")) %>' alt='<%# Eval("Codigo")%>' height="90" width="60" /> </td> </tr> <tr> <td colspan="2">

ListView, DataPager, LinqDataSource: LinqDataSource Selecting event fire twice


Dear all,

In my web app, I used LinqDataSource, ListView and DataPager (.NET 3.5 sp1) to implement search feature with paging. I have a button to trigger the search.

But In the first time, the Selecting event of LinqDataSource fire twice and I don't know why (I debugged my code very carefully). I don't use QueryString with DataPager and assign PageSize of DataPager in the first time of page load to prevent the ListView bind again (as in some instructions I found in forum)

Have anyone seen this problem before? And If possible, can you give me some instructions to try?

I can't post my code because it's quite large.

Thank you very much


Developer, CSC Vietnam


DataPager Manual input From Listview Control


Hi There,

I've been trying to marry up the listview and the Data pager with my own, Database class that pulls the information from the database.

I can display the information ok no problem, fortunately this time I know what the problem is, but I cannot figure out a way around the problem.

In my Page_Load event I fill out the listview accordingly:


Dim mList As List(Of Object) = mDbase.Record.Items("SELECT TBLResults.ID, Draw, [Date], B1, B2, B3, B4, B5, B6, BB, Jackpot, Wins, Machine, BallSet FROM TBLResults, TBLMachine WHERE TBLResults.MachineID=TBLMachine.ID ORDER BY Draw", GetType(ResultItem))


     Me.ListView1.DataSource = mList





The problem lies in the postback, I need to figure out a way get the information as to what state the DataPager is in so I could update the Query accordingly.

I know there is a StartRowIndex avaialbe but this does not get updated in the Page_Load event.

Has anybody got any ideas?

WPF: how to change the ListView cell template if the content is too long, it will display as Charact


We have used the GridView inside the ListView. We fix the column width (see the following link):


if the content is too long in one cell (since we fix the column width), we want it display as CharacterEllipsis at the end

just like the TextBlock we can define TextTrimming="CharacterEllipsis"

how can we achive it?


we have used the ListViewItemStyle as following, can we modify the <GridViewRowPresenter  /> section to achive it?

  <!--ItemContainerStyle with the Trigger for selection x:Key="ListViewItemStyle"-->
  <Style x:Key="ListViewItemStyle" TargetType="{x:Type ListViewItem}">
   <Setter Property="Background" Value="Transparent"/>
   <Setter Property="HorizontalContentAlignment" Value="Center"/>
   <Setter Property="VerticalContentAlignment" Value="Center"/>
   <Setter Property="Foreground" Value="Black"/>
   <Setter Property="Margin" Value="5,0,5,0&q

Group Parent-Child attributes with same display value


Hi all, I am very new to SSAS and have a question that I can't seem to answer anywhere

I may want to implement a parent-child attribute (depending on limitations). If I have the following hierarchical structure




Cost Centre




ListView with DataPager problem on ASP.NET 4


I'm currently working on upgrading an existing ASP.NET 3.5 app to ASP.NET 4 and I found a rather odd behavior with a ListView and DataPager. I'm using a ListView with an ObjectDataSource and in the ListView I have a DataPager with a NumericPagerField. On my 3.5 web app the page will display the ListView properly and will display the page number links at the bottom, where the DataPager is located. If I go to the last page and delete row by row until all are gone, the ListView will automatically page to the previous page. This is all behavior out-out-the-box since I don't have any special code for paging.

When I run the same app on ASP.NET 4 the behavior changes. The ListView no longer automatically pages to the previous page and I'm left with an empty list, with no way to get back to the previous pages even though there is still data to be retrieved. I get no DataPager control at the bottom because at this point what the ListView is displaying is the EmptyDataTemplate.

The way I've been able to reproduce this is by creating two web apps as follows:

Using Visual Studio 2010 Premium (a release version, not a demo or preview)

Create an empty web application (I called mine WebApplication1) using ASP.NET 3.5 and create a new web form called WebForm1.aspx

Use the following code:

<%@ Page L
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend