SlideShare a Scribd company logo
1 of 9
Solving a frustrating GridView shortcoming By Roger Pence How to solve a frustrating GridView problem… while learning a cool OO technique: decorator classes.
The problem ,[object Object],[object Object],[object Object],[object Object]
The problem ,[object Object],[object Object],[object Object],[object Object]
Or… ,[object Object],[object Object],[object Object],[object Object]
Fixing the problem…  the first pass BegSr gvCust_RowCreated Access(*Private) + Event(*This.gvCust.RowCreated) DclSrParm sender Type(*Object) DclSrParm e  Type(GridViewRowEventArgs) DclFld lb  Type( LinkButton )  DclFld RowCounter Type( *Integer4 ) Static( *Yes )  If ( e.Row.RowType = DataControlRowType.DataRow  )  ForEach tc Type( TableCell ) Collection( e.Row.Cells )  If ( tc.Controls.Count > 0 ) lb = tc.Controls[ 0 ] *As LinkButton If ( lb <> *Nothing )  lb.CommandArgument = RowCounter EndIf  EndIf  EndFor  RowCounter += 1  EndIf  EndSr In the RowCreated event, set each LinkButton’s CommandArgument property to the ordinal row number
Fixing the problem…  the first pass BegSr gvCust_RowCommand Access(*Private) + Event(*This.gvCust.RowCommand) DclSrParm sender Type(*Object) DclSrParm e  Type( GridViewCommandEventArgs ) // Column clicked available in e.CommandName. lblColumnSelected.Text = e.CommandName  // Row clicked available in e.CommandArgument. lblRowSelected.Text = e.CommandArgument EndSr This makes the CommandButton’s CommandName available in e’s CommandName property and the row clicked in e’s CommandArgument property.
Fixing the problem with a decorator class ,[object Object],[object Object]
Decorator classes ,[object Object],[object Object],[object Object],[object Object]
Put patterns on your  to-do list! ,[object Object],[object Object]

More Related Content

Similar to Fixing an annoying GridView problem

Inventory management
Inventory managementInventory management
Inventory management
Rajeev Sharan
 
Session 3 Bai 3 ve winform
Session 3 Bai 3 ve winformSession 3 Bai 3 ve winform
Session 3 Bai 3 ve winform
mrtom16071980
 
Csharp4 delegates lambda_and_events
Csharp4 delegates lambda_and_eventsCsharp4 delegates lambda_and_events
Csharp4 delegates lambda_and_events
Abed Bukhari
 

Similar to Fixing an annoying GridView problem (20)

4.7.14&amp;17.7.14&amp;23.6.15&amp;10.9.15
4.7.14&amp;17.7.14&amp;23.6.15&amp;10.9.154.7.14&amp;17.7.14&amp;23.6.15&amp;10.9.15
4.7.14&amp;17.7.14&amp;23.6.15&amp;10.9.15
 
The Ring programming language version 1.3 book - Part 5 of 88
The Ring programming language version 1.3 book - Part 5 of 88The Ring programming language version 1.3 book - Part 5 of 88
The Ring programming language version 1.3 book - Part 5 of 88
 
VB net lab.pdf
VB net lab.pdfVB net lab.pdf
VB net lab.pdf
 
Inventory management
Inventory managementInventory management
Inventory management
 
Controls events
Controls eventsControls events
Controls events
 
The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189
 
The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88
 
The Ring programming language version 1.5.2 book - Part 175 of 181
The Ring programming language version 1.5.2 book - Part 175 of 181The Ring programming language version 1.5.2 book - Part 175 of 181
The Ring programming language version 1.5.2 book - Part 175 of 181
 
Ete programs
Ete programsEte programs
Ete programs
 
Session 3 Bai 3 ve winform
Session 3 Bai 3 ve winformSession 3 Bai 3 ve winform
Session 3 Bai 3 ve winform
 
SPF WinForm Programs
SPF WinForm ProgramsSPF WinForm Programs
SPF WinForm Programs
 
WPF Controls
WPF ControlsWPF Controls
WPF Controls
 
Membuat aplikasi penjualan buku sederhana
Membuat aplikasi penjualan buku sederhanaMembuat aplikasi penjualan buku sederhana
Membuat aplikasi penjualan buku sederhana
 
Csharp4 delegates lambda_and_events
Csharp4 delegates lambda_and_eventsCsharp4 delegates lambda_and_events
Csharp4 delegates lambda_and_events
 
Kode vb.net
Kode vb.netKode vb.net
Kode vb.net
 
Kode vb.net
Kode vb.netKode vb.net
Kode vb.net
 
Web Design & Development - Session 6
Web Design & Development - Session 6Web Design & Development - Session 6
Web Design & Development - Session 6
 
Reactive fsharp
Reactive fsharpReactive fsharp
Reactive fsharp
 
The Ring programming language version 1.4 book - Part 29 of 30
The Ring programming language version 1.4 book - Part 29 of 30The Ring programming language version 1.4 book - Part 29 of 30
The Ring programming language version 1.4 book - Part 29 of 30
 
ITS-16163-Module 8-Graphic User Interface (GUI)
ITS-16163-Module 8-Graphic User Interface (GUI)ITS-16163-Module 8-Graphic User Interface (GUI)
ITS-16163-Module 8-Graphic User Interface (GUI)
 

More from Roger Pence (7)

Stop validating user input like a rookie
Stop validating user input like a rookieStop validating user input like a rookie
Stop validating user input like a rookie
 
What's new in AVR 12.0 and VS 2013
What's new in AVR 12.0 and VS 2013What's new in AVR 12.0 and VS 2013
What's new in AVR 12.0 and VS 2013
 
All you know about ASP.NET deployment is wrong!
All you know about ASP.NET deployment is wrong!All you know about ASP.NET deployment is wrong!
All you know about ASP.NET deployment is wrong!
 
Browser tools
Browser toolsBrowser tools
Browser tools
 
Using formal testing to make better AVR apps
Using formal testing to make better AVR appsUsing formal testing to make better AVR apps
Using formal testing to make better AVR apps
 
Using connection pooling for better AVR Web performance
Using connection pooling for better AVR Web performanceUsing connection pooling for better AVR Web performance
Using connection pooling for better AVR Web performance
 
Strategic guidance
Strategic guidanceStrategic guidance
Strategic guidance
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Fixing an annoying GridView problem

  • 1. Solving a frustrating GridView shortcoming By Roger Pence How to solve a frustrating GridView problem… while learning a cool OO technique: decorator classes.
  • 2.
  • 3.
  • 4.
  • 5. Fixing the problem… the first pass BegSr gvCust_RowCreated Access(*Private) + Event(*This.gvCust.RowCreated) DclSrParm sender Type(*Object) DclSrParm e Type(GridViewRowEventArgs) DclFld lb Type( LinkButton ) DclFld RowCounter Type( *Integer4 ) Static( *Yes ) If ( e.Row.RowType = DataControlRowType.DataRow ) ForEach tc Type( TableCell ) Collection( e.Row.Cells ) If ( tc.Controls.Count > 0 ) lb = tc.Controls[ 0 ] *As LinkButton If ( lb <> *Nothing ) lb.CommandArgument = RowCounter EndIf EndIf EndFor RowCounter += 1 EndIf EndSr In the RowCreated event, set each LinkButton’s CommandArgument property to the ordinal row number
  • 6. Fixing the problem… the first pass BegSr gvCust_RowCommand Access(*Private) + Event(*This.gvCust.RowCommand) DclSrParm sender Type(*Object) DclSrParm e Type( GridViewCommandEventArgs ) // Column clicked available in e.CommandName. lblColumnSelected.Text = e.CommandName // Row clicked available in e.CommandArgument. lblRowSelected.Text = e.CommandArgument EndSr This makes the CommandButton’s CommandName available in e’s CommandName property and the row clicked in e’s CommandArgument property.
  • 7.
  • 8.
  • 9.

Editor's Notes

  1. Click to add notes