473,661 Members | 2,502 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGrid event handling problem

I have a DataGrid which I am adding to the page dynamically at the Init stage
of the page load. The DataGrid has AutoGenerateCol umns turned off, has
BoundColumns and is bound to a DataView for its’ data source. I have also
added a TemplateColumn which is defined in a derived class and contains an
ImageButton. The derived TemplateColumn class contains an event handler for
DataBinding and in this handler I assign the ImageButton ID. The page that
contains my DataGrid contains two event handlers ItemCommand and SortCommand.
I have recently posted regarding a toggled sorting, which I have implemented
successfully. Although, since implementing the sorting I now have a very
strange behaviour occurring. When testing the toggled sorting I noticed that
the ItemCommand and SortCommand events stop firing if the columns are sorted
more than once, i.e. If you click the ImageButton (TemplateColumn ) after
clicking the column headers more than once the page refreshes but neither the
ItemCommand or the SortCommand event fires. This is almost as if the event
delegate is lost for the TemplateColumn on the second round trip. Anyone
ideas would be gratefully received!
--
MG
Jul 3 '06 #1
1 3080
I'm sure the problem here lies with the fact that in the Init event handler
when I am building the DataGrid I declare a TemplateColumn and create an
ImageButton but during the SortCommand event handler I am re-binding the
datasource after the sort but I am not re-creating the TemplateColumn. Do I
need to remove the TemplateColumn and re-add it in the SortCommand event
handler? or is there an easier way to re-bind the TemplateColumn to the
datasource?
--
MG
"Mark Gilkes" wrote:
I have a DataGrid which I am adding to the page dynamically at the Init stage
of the page load. The DataGrid has AutoGenerateCol umns turned off, has
BoundColumns and is bound to a DataView for its’ data source. I have also
added a TemplateColumn which is defined in a derived class and contains an
ImageButton. The derived TemplateColumn class contains an event handler for
DataBinding and in this handler I assign the ImageButton ID. The page that
contains my DataGrid contains two event handlers ItemCommand and SortCommand.
I have recently posted regarding a toggled sorting, which I have implemented
successfully. Although, since implementing the sorting I now have a very
strange behaviour occurring. When testing the toggled sorting I noticed that
the ItemCommand and SortCommand events stop firing if the columns are sorted
more than once, i.e. If you click the ImageButton (TemplateColumn ) after
clicking the column headers more than once the page refreshes but neither the
ItemCommand or the SortCommand event fires. This is almost as if the event
delegate is lost for the TemplateColumn on the second round trip. Anyone
ideas would be gratefully received!
--
MG
Jul 3 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2742
by: SammyBar | last post by:
Hi, I'm trying to bind a custom collection class to a data grid, following the guidelines from the article http://msdn.microsoft.com/msdnmag/issues/05/08/CollectionsandDataBinding/default.aspx. The problem is the article is in VisualBasic. I already get the collection to be recognized as a Data Source by the IDE. It populated the DataGrid correctly from the fields on the items object of the collection, but I can't get the DataGrid to...
5
12229
by: John Richardson | last post by:
I've been bothered for some time about my DataGrid not populating my rows very quickly. I have about 10K rows loading into the grid. I create a datatable dt with 2 columns, an ID and a display. The ID is a member of the keys array. I then create a DataView dv over the table, and sort it by Display and ID column (in case of duplicate Display). I then set my DataGrid.DataSource = dv; I then load the datatable with my rows, and this is...
0
1331
by: Sam | last post by:
Hi, I have a class that receives a DataGrid control and populates it. However, I need to do an OnItemCreated event because if I'm missing data in a certain column, I display a HyperLink control in the DataGrid so that the user can enter the missing data. If there is data, I hide the HyperLink control. The problem is I pass the DataGrid control to a class and let the class populate it and return it to the ASPX page. I just don't know...
2
2382
by: andla | last post by:
Hi, How does events fire in a datagrid. I know about the problem if turning the viewstate off the events wil not fire properly even if I rebind the control in every postback. S then I started to think how does .Net do it if I turn the viewstat on. If you use the Request.Form then you can get all the controls tha
4
2116
by: The Alchemist | last post by:
I am having a problem with a dynamically-generated Datagrid. It is important to point out that this problem does not exist with a design-time created Datagrid, but only with a dynamically generated Datagrid in a Web Custom Control (WCC) : The datagrid has LinkButton Column which has a select LinkButton for each row. When this button is clicked, the Datagrid raises its 'ItemCommand' event which captures the information for that row and...
4
7365
by: Suzanne | last post by:
Hi all, I'm having problems with datagrids and the currentcellchanged event. My problem is this: I have a datagrid on a form, if the user changes the text in a cell on the datagrid then tries to close the form via a button on the toolbar (with going to another cell in the datagrid)I want to be able to popup a messagebox to the user asking them if they want to keep their changes. At the momment I'm accomplishing this by a property that...
1
1737
by: mike | last post by:
I posted before and got the reply below, which really doesn't help me at all. I really didn't understand what the responder was talking about I'd like someone who is a microsoft expert to help me with some specifics on this problem: I have to do some specific data verification before saving a row or group of rows to the database (the data validation in the datagrid really doesn't help all that
5
3337
by: Steve | last post by:
I have a datagrid in a WinForm. When the user edits an entry in the datagrid, after he leaves that field, I would like to do some cheking. What event fires when the user does that? I need to make sure that the value he modified does not create a dup value in my DB. Thank you for your help, Steve
2
4044
by: shuckjunkmail | last post by:
It was suggested that I re-submit this question as a new post rather than adding onto an old and unanswered post. The basic problem has to do with the .NET datagrid and sorting. I am having trouble getting the correct row of data from the datagrid immediately after re-sorting the datagrid. I am using the dataview for accessing the data and am using the following code as previously mentioned in a different post: Dim bm As...
0
8343
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8855
Oralloy
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...
1
8545
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,...
0
7364
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, 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...
1
6185
isladogs
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...
0
5653
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();...
0
4179
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...
0
4346
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.