Hello all,
I have an application that has a ListView and a DataSet. When btnRemove is
clicked, the method btnRemove_Click is being fired, which compares 2 keys to
find a unique match on a dataRow which then should be removed, through a
foreach loop and then the loop is being exited by break statement.
The problem is that for some reason, my (custom control) button is being
fired again, which may trigger an Exception since there might not be any
records left in the DataSet and ListView.
Below is the snippet of btnRemove_Click (object sender, EventArgs e)
Any thoughts why this is being fired twice?
Muchly appreciated,
Vincent
// Reference the selected ListViewItem
ListViewItem lvi = new ListViewItem();
lvi = lvSources.Selec tedItems[0];
// Loop through the DataSet and find the corresponding record.
foreach(DataRow row in dsMaster.Tables["SrcTable"].Rows)
{
if(row["Source"].Equals(lvi.Sub Items[0].Text) &&
row["OrigSource "].Equals(lvi.Sub Items[1].Text))
{
row.Delete();
lvSources.Items .Remove(lvi);
dsMaster.Tables["SrcTable"].AcceptChanges( );
return;
}
} 4 1606
hi!
for that i would ask 'if(lvSources.S electedItems.Co unt > 0){...}' ...
and i would disable the button at beginning method and enable (if
items-Count > 0) it at the end of the click-method
ciao
"Vincent" wrote: Hello all,
I have an application that has a ListView and a DataSet. When btnRemove is clicked, the method btnRemove_Click is being fired, which compares 2 keys to find a unique match on a dataRow which then should be removed, through a foreach loop and then the loop is being exited by break statement.
The problem is that for some reason, my (custom control) button is being fired again, which may trigger an Exception since there might not be any records left in the DataSet and ListView.
Below is the snippet of btnRemove_Click (object sender, EventArgs e) Any thoughts why this is being fired twice?
Muchly appreciated, Vincent
// Reference the selected ListViewItem ListViewItem lvi = new ListViewItem(); lvi = lvSources.Selec tedItems[0]; // Loop through the DataSet and find the corresponding record. foreach(DataRow row in dsMaster.Tables["SrcTable"].Rows) { if(row["Source"].Equals(lvi.Sub Items[0].Text) && row["OrigSource "].Equals(lvi.Sub Items[1].Text)) { row.Delete(); lvSources.Items .Remove(lvi); dsMaster.Tables["SrcTable"].AcceptChanges( ); return; } }
Hi Darkblue,
I came to that conclusion, but still it seems odd to me that the click
method is being called twice. Are there any known issues with custom controls
derived from System.Windows. Forms.Button?
"darkblue progger" wrote: hi!
for that i would ask 'if(lvSources.S electedItems.Co unt > 0){...}' ... and i would disable the button at beginning method and enable (if items-Count > 0) it at the end of the click-method
ciao
"Vincent" wrote:
Hello all,
I have an application that has a ListView and a DataSet. When btnRemove is clicked, the method btnRemove_Click is being fired, which compares 2 keys to find a unique match on a dataRow which then should be removed, through a foreach loop and then the loop is being exited by break statement.
The problem is that for some reason, my (custom control) button is being fired again, which may trigger an Exception since there might not be any records left in the DataSet and ListView.
Below is the snippet of btnRemove_Click (object sender, EventArgs e) Any thoughts why this is being fired twice?
Muchly appreciated, Vincent
// Reference the selected ListViewItem ListViewItem lvi = new ListViewItem(); lvi = lvSources.Selec tedItems[0]; // Loop through the DataSet and find the corresponding record. foreach(DataRow row in dsMaster.Tables["SrcTable"].Rows) { if(row["Source"].Equals(lvi.Sub Items[0].Text) && row["OrigSource "].Equals(lvi.Sub Items[1].Text)) { row.Delete(); lvSources.Items .Remove(lvi); dsMaster.Tables["SrcTable"].AcceptChanges( ); return; } }
Hi Vincent,
I think that your problem lies not in the handler's method.
It seems that you've assign the same event handler twice to
the "Click" event.
HTH
Marcin Hello all,
I have an application that has a ListView and a DataSet. When btnRemove is clicked, the method btnRemove_Click is being fired, which compares 2 keys to find a unique match on a dataRow which then should be removed, through a foreach loop and then the loop is being exited by break statement.
The problem is that for some reason, my (custom control) button is being fired again, which may trigger an Exception since there might not be any records left in the DataSet and ListView.
Below is the snippet of btnRemove_Click (object sender, EventArgs e) Any thoughts why this is being fired twice?
Muchly appreciated, Vincent
// Reference the selected ListViewItem ListViewItem lvi = new ListViewItem(); lvi = lvSources.Selec tedItems[0]; // Loop through the DataSet and find the corresponding record. foreach(DataRow row in dsMaster.Tables["SrcTable"].Rows) { if(row["Source"].Equals(lvi.Sub Items[0].Text) && row["OrigSource "].Equals(lvi.Sub Items[1].Text)) { row.Delete(); lvSources.Items .Remove(lvi); dsMaster.Tables["SrcTable"].AcceptChanges( ); return; } }
Hi Marcin,
I did a Find in Visual Studio on btnRemove.Click but I can only find it once.
Are there any other places except in the form where this can be done?
Thanks,
Vincent This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Michael Johnson Jr. |
last post by:
I am trying to handle a button click event, which updates a web control
table with data. The button is dynamically created in the table itself.
When I call updateTable() in the Page_Load the new data from the button is
not available at this time as to allow the table to properly update.
So basically, I need to call UpdateTable() twice, once from page load and
once from button. This causes problems with my application, and I was
trying...
|
by: erdem |
last post by:
hi,
i have a problem with asp.net
when i was debugging
i put breakpoint to pageload event and then i discovered that
page is loaded once (explorer shows full page correctly but continues
loading)
but then
somehow page load executes again
and then page is displayed...
but there is different thing. when page executes page load second time,,
|
by: Oz |
last post by:
Hi
Using VS.NET 2003, Windows XP SP1,
We have a page which has been developed using ASP.NET. On it, is a button
which when clicked is supposed to add some data to a table. When the button
is selected, it causes the ServerClick event to be called twice.
Here's the code: You'll see that there are two grids on the page, and that
the function SetupDataGrid populates data to the two grid. There are also
|
by: Imran Aziz |
last post by:
Hello All,
I have a search text and button that post data and my button handler
filters the repeater control. However when the button is clicked the first
time. The page_load event is being called twice, once with postback true,
and second time without postback. This only happens for this button. How can
I sort out this issue, any clues what to look for to get this sorted please.
<p>Search Bookmarks: <asp:TextBox ID="txtSearch"...
|
by: Diffident |
last post by:
Hello All,
I have an asp:button and I have tied an eventhandler to this button's click
event which means that the eventhandler should be executed everytime I click
the button. But to my frustration, the eventhandler does not get executed
everytime I click the button. I have to click the button twice at times to
make sure that the event handler is being called. Why is the control behaving
in this way? This problem is not specific for a...
| |
by: rajendra.mishra |
last post by:
Hi...
I have a frame(Report.htm) which has two aspx pages one for
header(header.aspx) and the other for displaying reports(Report.aspx).
when Report.htm is called Report.aspx executes twice. I have checked
for autoeventwireup. it is set to false in all the pages.cant say why
is this happenning or i suppose that for frames this is an existing
issue..
In Report.aspx i am generating an crystal report in PDF Format. I'LL
|
by: mosscliffe |
last post by:
I am sorry but I am all very new and slow at understanding all this
ASP.NET2.
I found some code which showed how to page with a repeater. All very
excited as I had been looking for this all day. It worked wonderfully,
but it was in C# So I converted it to VB with
http://www.developerfusion.co.uk/utilities/convertcsharptovb.aspx
It got upset about private and so I changed those to protected
|
by: Aleks Kleyn |
last post by:
In asp.net I can put code for button click event. However I come to this
event twice. What is the reason and how to prevent or check second entry to
this event. I need to make sure that i do not run the same code twice.
Aleks Kleyn
|
by: Tom Van den Brandt |
last post by:
Hi,
I wrote a simple windows service that includes a FileSystemWatcher.
After building and installing the service (installutil) I notice that
the service executes twice. I included a write to the application
eventlog in OnStart ("service has started and is ready to watch the
filesystem") and this results in two entries in the eventlog.
Also, the handler for the FileSystemWatcher seems to be fired twice if
something happens with a...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |