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


Top 5 Contributors of the Month
david stephan
Post New Web Links

Listview Item RemoveAt

Posted By:      Posted Date: September 21, 2010    Points: 0   Category :ASP.Net
 

Hi There,

I'm trying to delete a item from the listview.

I can delete the item from the database ok, but the listview item does not get removed, I could do a Response.Redirect to redisply the page but this is overkill?

Below is my code:

 Private Sub ListView1_ItemDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewDeleteEventArgs) Handles ListView1.ItemDeleting

  Dim key As String = Me.ListView1.DataKeys(e.ItemIndex).Value.ToString()

  Me.ListView1.Items.RemoveAt(e.ItemIndex)
    'Dim mDbase As New SQL40.Database.SQL.SQL(<Sever>, <Database>, "", "", True)
    ' mDbase.Open()
    ' mDbase.Record.Delete("DELETE FROM TBLResults WHERE ID=" & key)
    ' mDbase.Close()
 End Sub


 




View Complete Post


More Related Resource Links

listview 3.5 bind dropdownlists edit item template VB.NET

  

I am trying to do this with many issues of data binding doubling the amount and not setting selectedValue on dropdownlist. I have read some posts and they help but I am missing a crucial piece. My problem is that my dropdownlist is doubling the amount of records for the dropdownlist. Instead of "YES;NO;SELECT A VALUE", I am getting "YES;NO;SELECT A VALUE;YES;NO;YES;NO". My database is correct with the UPDATE part but the rebind after update is failing horribly.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If IsPostBack Then
            If Session("ACTIVETAB").ToString() = Session("SUBCONTRACTSATABNO").ToString() Then
                BindData()
            End If
        Else
        End If
    End Sub

    Public Function loadlookups(ByVal id As String, ByVal e As System.Web.UI.WebControls.ListViewItemEventArgs) As DataTable
        Select Case id
            Case "ddlCertReceived"
                dt = GetLookupTable("SubcontractsA", "Sub 1 Cert Received")
                Dim ddlCertReceived As DropDownList = _
                CType(e.Item.FindControl("ddlCertReceived"), DropDownList)
                ddlCertReceived.DataSource = dt
                ddlCertReceived.DataTextField = "lup_text"
  

listview with button in item template - how do I handle the click event?

  
Hello,Using a listview control for the first time... I need a button for each item, and of course I need to handle the click event for the buttons... upon clicking a particular button I of course need to know which item the button is associated with so the appropriate action can be taken...In VS, I can't select the button and see my list of available events in the properties window like is normally done for controls outside of templates like this... what do I need to do?

VS2008 and C#: How to create a short cut for a selected item in a ListView/TreeView ?

  
How to create a short cut for a selected item from a ListView/TreeView ? Is it possible to provide a smaple code ? Thanks,

Is there a way to have more than 1 "item placeholder" in a listview to accomplish having multiple in

  
I need to have 3 different sections of a listview act as a repeater, but independen of each other.  Each will have identical column headings, but different datasources.  They will all share the same Heading, but each will have a different footer.  In other words, I need to have 3 different "itemPlaceholders" in one listview. Can that be done. Presently, I have a panel with three listviews nested together.  It works fine except that the formatting of them doesn't stay consistent.  Thanks    

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>

Load byte[] into a ListView like in a hex editor (each byte should be an item)

  
Hi, I am writing some sort of Hex Editor in C# .NET 3.5 WPF. My input is a binary file, which can be very large (at least 10MB). I want to benfit from WPF's UI virtualization. For that I've tried using the DataGrid or the ListView. However, those 2 have a concept of each row being an item, and the hex dump means each cell is an item. Trying to copy the byte[] to a DataTable or a new class that implements IEnumerable takes too much memory and hangs the application. Also creating many strings / TextBoxes will be very expensive. Example of an input: 37 AA B1 00 01 05 03 33 45 66 23 45 67 43 32 12 47 5A 61 70 01 05 83 99 45 45 23 25 67 43 32 12 56 34 45 67 I would like to show like this: 37 AA B1 00 01 05 03 33 45 66 23 45 67 43 32 12 47 5A 61 70 01 05 83 99 45 45 23 25 67 43 32 12 56 34 45 67 I've encountered the wrap panel (which might suit as well with Horizontal orientation) but wrap panel has no virtualization. I'm fairly new to WPF, but I've read a lot for 2 weeks in all the web... and tried a lot!!! But still, I can't seem to find a good solution to my problem. Please help :( Thanks in advance, Michal.

ListView.ItemTemplate with Button. Command doesn't execute when item is selected

  
I have a listview with an item template that contains a button: <ListView ItemsSource="{Binding AllProducts}"> <ListView.ItemTemplate> <DataTemplate> <Grid> <Button Content="Add Supplier" Command="{Binding AddSupplier}"/> </Grid> </DataTemplate> </ListView.ItemTemplate> </ListView> When the listitem is not selected and the button is clicked, the command executes fine. However, if the listitem is selected, the command does not execute. I have tried putting click and mouse down event handlers on the button, but the events do not fire. Is there any way to make the command execute when the listitem is selected?

How to select some part of a text in listview item?

  

Dear all

I have a listview in WPF application, that I bind data in it using gridview. now I want to make a search for it. making search is simple but question is this I want to make a search that if user type 'a' then system will highlight all 'a' in list view. or if user type 'lis' the system will highlight all 'lis' in that listview.

Is it possible to highlight part of the text in side of listview item? or I have to select whole listviewitme? 

 

Thank you so much


Selecting an Listview Item

  

May be I'm trying to run before I can walk, but here goes, I find coding for ASP so frustrating it's just not logical JIM!

Anyways after my rant, as I'm a huge fan of the listview control in WinForms I'm trying to get the hang of it in ASP, wth not much luck so far.

I've got several questions I hope you guys/girls can answer

I'm trying to make the listview winforms-e

Select Item then update/Delete as required

(A) how to actually select the item and ire the event and then pickit up again to update/delete the item of either button is pressed.

Also the following is a snippet of code I have that when your over the item you can select it which goes to another ASP page so it can be edited(when finished that is!).

                <tr style="background-color: #DCDCDC;" onmouseover="this.style.backgroundColor='#FFCCFF'"
                    onmouseout="this.style.backgroundColor='gainsboro'"> 
                    <a href="Draw.aspx?ID=<%# Eval("ID")%>" style="text-decoration: none; color: rgb(0,0,0);">                  
                    <td style="text-align: right;">
                        <asp:Label ID="Draw" runat="server"><%#

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">

Can't style selected item in ListView when GridView is used

  
Below is a simple window that contains a ListView. Note that it is overriding the SystemColors.HighlightBrushKey to change the color of the selected item.
Works fine, unless  the ListView.View block is enabled, and a GridView is defined.

When that is done, the GridView seems to enforce its own idea of what the selected row should look like.

How can I style the selected row of a ListView using a GridView?


<Window x:Class="WpfApplication1.Window3"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window3" Height="300" Width="300">

    <Grid>
        <ListView>
            <ListView.ItemContainerStyle>
                <Style>
                    <Style.Resources>
                    &nbs

Zooming a grouped listview item in WPF

  

I have a listview that is bound to a ListCollectionView containing my objects, grouped (by some object property such as a state, etc).  This results in the first row in the listview containing an expander, and the listview is populated with one column per state.   Each column can have varying numbers of items (rows) displayed based on how many objects match the field that the listview is being grouped by.  This seems to work OK for what I am trying to build.

I've added code so that when the mouse hovers over a listview item, I can use triggers to show / hide several buttons.  One example is an edit button - clicking on this brings up a window that allows me to edit the object.  Hovering over another button brings up a templated tooltip that I have customized.  This seems to work well. 

But, I have a third button on this window.  The behavior for this button is what I am unable to get working.  When I hover over or click on this button (doesn't really matter), I want the listview item to scale by x% AND be brought to the front of any siblings next to it.  I have been unable to get this to work or find a similar example.

If I remove the step of having to interact with a button on the listviewitem, I can add a transform for the border on the listview item so that when

Highlight ListView item

  

Hi All.

I would like to highlight added new ListView item or item was saved after modification. 

Public Sub ListView1_SourceUpdated(ByVal CurrentItem As Integer)
 If Me.CollectionView1.Count > 0 Then
  If CurrentItem = 0 Then
   Me.ListView1.SelectedValue = Me.CollectionView1.CurrentItem("User_Id")
  Else
   Me.ListView1.SelectedValue = CurrentItem
  End If
 End If
End Sub

 

When I saved new or modified record the item of ListView didn't highlight. How to fix that problem?

Thanks.


Not understanding how to RemoveAt() in ObservableCollection ListView

  

I've created an MRU listView with buttons in WPF and I know how to determine which itme in the listview was clicked but I'm having trouble removing the item from the listview using remove at.

I want to replicate the listview used word 2010.

I'm writing key's to the registry to store Name "Item1" etc. with the Data "D:\\Somefile.txt"

I'll add "[true]" etc. as a pin state later.

I need to sync my registry with my List and I can read the list in fine and display the buttons.

I just need to be able to update the registry and list state when a new item is added. 

Previously I removed the key if it existed using a string compare in c#, but now I'm using databinding and moving through the Observable Collection and don't understand how since I have two items in my collection, MRUFileName and MRUPath, 

My collection is setup as so:

First I've declared my collection

ObservableCollection<MRUClass> _filename = new ObservableCollection<MRUClass>();    // MRU Collection
then I setup my Getter/Setters in my class:

  public

select listview item

  

Hi All.

I would like to select added ListView item in case when ListView has checkbox column.

XAML

<Window.Resources>
 <DataTemplate x:Key="CheckBoxCell">
  <StackPanel Orientation="Horizontal">
   <CheckBox Name="chk" IsChecked="{Binding Path=IsSelected, RelativeSource={RelativeSou

Listview selected item with Linkbutton

  

<asp:ListView ID="pricedRoomListView" runat="server" DataKeyNames="room_id" DataSourceID="pricedRoomsObjDataSource"
                            EnableModelValidation="True" OnItemDataBound="pricedRoomListViewOnItemDataBound" OnItemCommand="bidRoomFromListView">
                            <AlternatingItemTemplate>
                                <tr style="background-color: #E2E6FC;">
    

Listview & GridView , select an item

  

hey,

 

i create a ListView with a GridView and some GridViewColumn´s in therein:

<ListView ItemsSource="{Binding Records}" x:Name="list" Margin="21,8,21,18.9" Grid.Row="2" Background="{StaticResource linearbrush2}" HorizontalContentAlignment="Center">
    <ListView.View>
     <GridView>
      <GridViewColumn  DisplayMemberBinding="{Binding hd_drive}" Width="35" Header=" Drive"/>
      <GridViewColumn  DisplayMemberBinding="{Binding browser_name}" Width="100" Header="Browsername"/>
      <GridViewColumn x:Name="defaultbrowserpath" DisplayMemberBinding="{Binding file_path}" Width="300" Header="Path" /> 
     </GridView>
    </ListView.View>
   </ListView>

the DisplayMemberBinding-Property points to a ObservableCollection, with the Name Records,

Categories: 
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