.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

Problem with ListView and SelectionMode="Single"

Posted By:      Posted Date: September 03, 2010    Points: 0   Category :WPF
  I have the following XAML: <Grid>       <ListView SelectionMode="Single" Height="100" HorizontalAlignment="Left" Margin="26,118,0,0" Name="listBox1" VerticalAlignment="Top" Width="120">       <ListView.View>       <GridView>       <GridViewColumn Header="Test"/>       </GridView>       </ListView.View>       <ListViewItem>Test</ListViewItem>       <ListViewItem>Test</ListViewItem>       <ListViewItem>Test</ListViewItem>       <ListViewItem>Test</ListViewItem>       <ListViewItem>Test</ListViewItem>       <ListViewItem>Test</ListViewItem>       <ListViewItem>Test</ListViewItem>       </ListView>       </Grid>       Just a stock ListView with SelectionMode="Single". Isn't SelectionMode="Single" supposed to be single selection mode? There seems to be a lot of weird stuff with the Ctrl-Key. I tested the same behavior in a standard W

View Complete Post

More Related Resource Links

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? 



A layout, mouse selection, ListView problem/question

I'm having a problem with a particular layout scenario, and how it interacts with a left mouse click in certain situations. I have 3 rows in a Grid.  The first is a ListView (Master), with the Row Height set to '*'. It's ItemSource is bound to a collection in a ViewModel, and its SelectedItem is bound to a value in the ViewModel.  When the SelectedItem is null, it should take up its entire container (the other 2 rows are invisible). The second row is the GridSplitter.  It's visibility is bound to a value in the ViewModel.  It's only visible when the SelectedItem in the Master ListView is not null.  It's GridRow height is set to Auto, and it's height is explicitly set to 5 (via a style). The third row is a sub-ListView that shows Detail data for the Master SelectedItem in the top ListView.  It's GridRow Height is set to zero by default, and if an item is selected in the Master ListView, it should become visible and have a set height (400 to start, via a binding on the Height of the row). The desired effect is that when an item is selected in the Master ListView, the Detail ListView becomes visible and the GridSplitter allows you to resize the top and bottom as needed.  If necessary, the ScrollBars become visible in the Master ListView to show any items that are now obscured by the Detail ListView (via the automatic scrolling featur

Problem with listview selection

I have the following problem (which I have seen documented in many places with no solution).  I populate a listview.  The steps I use are: Set the ItemsSource to nothing (VB) Set the ItemsSource to the collection to be bound to Set the selected item to nothing (VB) Set the selected item to the first item in the collection The problem is that when I use the down arrow key to change selection in the listview, the first time I use the down arrow nothing happens.  After that first glitch everything works.  I have seen many "solutions" but none that work. Any ideas?? Thanks LLoyd Sheen

C# ASP.NET Problem keeping scroll position SelectionMode="Multiple"

Have tried numerous solutions and nothing has worked.  I'm pretty sure that Javascript is required to get this functional. Thanks for your help!    Here is the code for file Search.aspx ===BEGIN<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="search.aspx.cs" Inherits="SearchApp.search" MasterPageFile="~/Site1.Master" EnableViewState="true"%> <asp:Content ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <fieldset> <legend style="text-align:center;"><b>Make Atleast one or multiple selections from one of the following categories</b></legend> <div class="wrapperserach"> <div> <div class="side-a"> County<asp:ListBox ID="Lcounty" runat="server" AutoPostBack="true" SelectionMode="Multiple" OnSelectedIndexChanged="Lcounty_SelectedIndexChanged" Width="140px"> <asp:ListItem value="1">Imperial</asp:ListItem>

Listview WebPart Selectedview problem

We have a problem with the Listview WebPart on our current project.Situation:We are building custom sitedefinitions for a portal site. In these site definition we add our webpart/features that have to be deployed with this sitedefinition.In that defintion (ONET.xml) we add a ListViewWebPart on the page. <View List="Whiteboard" BaseViewID="3" WebPartZoneID="Left" WebPartOrder="2"    Type="108" /> Sofar everything is going fine, we generate our webs with the definition and the webpart renders like it should on the page.We then add an item in the list (Discussion list). Again sofar everything fine. when we then try to click on the item to view it in the webpart the item seems to magically disappear from within the webpart. However the items stays in the list so it's not like it gets deleted.After some searching we found out that when we bind the selectedview on the webpart again (modify shared webpart -> selected view) the item reappears just as magically as it disappeared.The problem is that for our project we have to create more then 90 webs with this sitedefinition and it's not an option manually start clicking every web for this "bug".Whe tried two other ways to solve this problem without success.First way was to remove the listviewwebpart declaration from the ONET and add the webpart with C# code in

Profile synchronization problem - can successfully import single users but not from a group - can yo


I can successfully import a single user into SharePoint 2010 from AD (proves settings permissions are correct) and the number of user profiles increases and I can locate the user including profile data from active Directory. But when I try to import an Active Directory global security group no users get migrated. In fact the single users profile gets deleted.

Can somebody explain whether it is possible to migrate users into SharePoint 2010 from with security groups in Active Directory?

Also when I retried to import the group of users it deleted the single user that I had successfully imported, I didn’t think this was possible, I ran an incremental synchronization, i need to import roughly 2000 users and was going to do it in stages to make sure all users were imported but if the process can remove users then each sync run could be adding users and removing users, how will I ever keep track?

Below is the synchronization run report, are there logs files that could give me more information?

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

Javascripts single quote problem


Hi ,

I am calling a popup from anchor inside a gridview.

<a href="javascript:ShowSiteVirtualProfile('<%#Eval("Site").ToString().Replace("'", "\'")%>','<%#DataBinder.Eval(Container.DataItem,"Query").ToString().Replace("'", "\'")%>')"><%#DataBinder.Eval(Container.DataItem,"Site")%></a>

Its works fine. But a single quote in the text popup is not working.

Please give me a solution what I need to do now.

Problem with ListView' SelectionChanged event


I have a listview (C#) with some items representing metadata objects. Near this listview I have a Panel where the structure of selected metadata object is shown.

When user selects one item I want to show my Panel (with structure of this item).

When user doesn't select any item or selects many items I want to hide my Panel.

It works but there are a lot of blinks during selection changes. I've prepared workaround to this issue by checking in SelectionChanged event whether the number of selected items changed (none -> one, one -> many, many -> one, one -> none). If the number changed so I show or hide the panel, in other cases I don't do anything.

But one blink is still here. When I just move one-item selection from one item to another then SelectionChanged occures 2 times (for previous selected item and then for next selected item). So my check works incorrectly in this case: one item selection changes to none selection (first SelectionChanged event) and panel becomes hidden, then none selection changes to one item selection (second SelectionChanged event) and panel becomes shown. So user sees blinks.

How can I detect whether user deselected all items at all or just moved the selection from one item to another.

Thanks a lot. Sorry for my English:)

Problem filling labels with table data outside datalist using single call to db


On a single page, I'd like to fill 2 hyperlink controls as well as a datalist control with table data using one call to the database. The page looks like this:

<div id="PageContent">    
      Please select the district you wish to view below.</p>
      <asp:DropDownList ID="ddlDistrict" runat="server" CssClass="textbox" 
        DataTextField="DistrictName" DataValueField="DistrictId" AutoPostBack="True" 
    <p><asp:label ID="lblDistrictAbbrev" runat="server" Text="District Abbreviation: " />
      <asp:hyperlink ID="hyperlinkDistrictName" runat="server" 
        Text='' NavigateUrl="~/Contact/NationalCouncil.aspx" 
        Font-Bold="True" />
    <p><asp:label ID="lblDistrictCouncillor" runat="server" Text="District Councillor: " />
      <asp:hyperlink ID="hyperlinkCouncillor" runat="server" 
        Text='' NavigateUrl="~/Contact/NationalCouncil.a

ListView - Insert Problem



I have a ListView where I am trying to do an insert.

I put the property "oniteminserting" in the ListView, and created the method in the codebehind of the page.

When I try to insert a record, is not calling the method "ListView1_ItemInserting. I put a breakpoint in the method, but is not calling it.

To call the input method in ListView, I'm doing the following:

oniteminserting = "ListView1_ItemInserting"

And the method:

protected void ListView1_ItemInserting (object sender, ListViewInsertEventArgs e)

I tried to delete the method call in the listview, I went into design mode, I clicked in the ListView, I went into properties, events, I gave a double-click the event ItemInserting to recreate the method. But even so, the problem continues.

Does anyone know what might be happening?

* Sorry for bad English. =)

there are some problem in finding the index of listview


how we find the listview index of row in case of item databind

listView - ItemDataBound event - problem casting to DataRowView to get to underlying data?


System.InvalidCastException was unhandled by user code
  Message="Unable to cast object of type 'WebSTAR.JobListItem' to type 'System.Data.DataRowView'."
       at WebSTAR.Default.ListViewRecentJobs_ItemDataBound(Object sender, ListViewItemEventArgs e) in C:\Users\djc\Documents\Visual Studio 2008\Projects\WebSTAR\WebSTAR\Default.aspx.cs:line 255
       at System.Web.UI.WebControls.ListView.OnItemDataBound(ListViewItemEventArgs e)

Strange problem, unable to insert single quote (already add in an extra single quote) for one partic

I have a very strange problem, I can update the table with single quote, but I cannot insert single quote. It only happen for this particular table in the database. Is there any suggestion on what I should look at?

I had already added in an extra single quote in my sql statement, something like this:

insert into Table_1 VALUES ('hello''s world','xxx')

Single User MySite Creation problem

Yeah... So I left the company I work for about 8 months ago, and came back to it about 2 months ago.  During my absence, my teammates deleted my AD account (as they should have).  Let me preface this by saying that MySite creation works for everyone else but me.

When I click on MySite I get the create My Site page, I can choose my language, but after pressing OK, I get this error:  "There has been an error creating the personal site. Contact your site administrator for more information."

I'm really not sure where to start on this one...  And am willing to give up quickly and just rename my account.  Does anyone have any ideas before I go that route?


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!

Problem to group radio button across gridview rows

In general no one can easily group or make a single selection from radio button list inside gridview rows. There are a lot of way to make a single or unique selection from list. Here i want to share how i can address this problem in the most easiest way. Googling the problem most of the cases i saw the grouping in horizontal way. Thats why i tried to group the radio buttons in vertical manner. Let i have a requirement like below:
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