473,396 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Calling ListView ItemUpdating event when a button outside the control is clicked?

I have a listview control in which I had replaced all the ItemTemplate labels with TextBoxs. I also have a command button on the page, when the button is clicked I am able to retreive the text in all the TextBoxes one by one by running a For..next loop. After reading the textboxes content I want to fire the ItemUpdating event for each row so that I can update all the rows at once.

I have the following code in the button_click event, but it does nothing
Expand|Select|Wrap|Line Numbers
  1.     Dim idcount As ListViewItem
  2.         Dim i As Int32
  3.         Dim ei As New ListViewUpdateEventArgs(i)
  4.         For Each idcount In ListView1.Items
  5.             ei.NewValues("Name") = DirectCast(ListView1.Items.Item(i).FindControl("NameLabel"), TextBox).Text
  6.             i = i + 1
  7.         Next
Is it not possible to update all the records at once through the above approach

I also tried another approach listed below with a light change, but with no results...
Expand|Select|Wrap|Line Numbers
  1.     Dim idcount As ListViewItem
  2.         Dim i As Int32
  3.         Dim ei As New ListViewUpdateEventArgs(i)
  4.         For Each idcount In ListView1.Items
  5.             ListView1_ItemUpdating(i, ei) '<-----
  6.             i = i + 1
  7.         Next
Please help
Jan 15 '09 #1
1 4066
Frinavale
9,735 Expert Mod 8TB
Why don't you just save the names into a list and create a function, called Update, that accepts the list as a parameter and updates the rows?

The ItemUpdating event is a ListView event. The ListView raises this even when an item is being updated. Your code can handle this event but your code cannot raise it.

It would make more sense just to create a method that does the updating rather than try and raise an event which you are going to handle in a method anyways.
Jan 20 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: John Lauwers | last post by:
I know you can edit the first column of the listview control, is there a way to edit the second and/or the other columns? greets John
0
by: Sandra | last post by:
I have a form with a list view control that has the checkboxes property set to true. This provides checkboxes as the first column in the listview. When a listviewitem is checked another form is...
6
by: Richard | last post by:
Hi. I use a ListView to display data in tabular form. Each ListView row corresponds to a data record. The ListView Item of the record is the record key or code. Each SubItem in that row...
1
by: Alan | last post by:
Hi All, Is it possible to add other controls to the ListView control in C# windows forms. i.e. I want to add a button column so to speak to the list view. You can do this sort of thing with the...
13
by: Maheshkumar.R | last post by:
hi groups, I have placed an listview control, i want to iterate thru the control and find the clicked event items. listView2.Items.Add(fname.ToString(), i); how i can perform the iteration...
2
by: Frank Schumacher | last post by:
Hi Folks, I have a problem with the order of events fired by ASP.NET. I found many articles which explaining the lifecycle of a site, but I found none which took the event from a Control on the...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
5
by: Martin Horn | last post by:
Hi all, I want to implement a listview with editable subitems and I assume the easiest way is to overlay a textbox over the item to be edited. With this in mind I have come up with: Using...
4
by: Pucca | last post by:
How can I tell a mouse right clicks over a listview item that's in a container panel. I only want to display a popup menu if the user right click the mouse over an item on the Listview. I don't...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.