Saturday, July 31, 2010     •  Login
 
   
 
   
   
   
 
 
     
 
   Welcome to my blog! Minimize
Mar 23

Written by: Daniel Balla
Fri, 23 Mar 2007 18:57:03 GMT

A couple days ago a friend asked me how can you make the ASP.NET validators validate the contents of a gridview at row level, so that each row works independently. For example, in the grid below use a requiredfieldvalidator on each row so that the Save button would validate the description textbox on the same row, but wouldn’t validate any of the other rows’ descriptions.



In this case, clicking the save button in the “Dairy products” row would cause the validation to suppress the postback, but clicking the save button of any other row wouldn’t.
The solution is simple: use the validation group bound to a unique row identifier. In our example (which displays the contents of the Categories table of the Northwind database) the binding would look like:

<asp:TextBox Width="300px" ID="txtDescription" runat="server" Text='<%# Bind<"Description"> %>' />
<asp:RequiredFieldValidator ID="reqDescription" runat="server" ControlToValidate="txtDescription" ErrorMessage="*" ValidationGroup='<%# Bind<"CategoryID"> %>' />
<asp:Button ID="butSave" runat="server" Text="Save" ValidationGroup='<%# Bind<"CategoryID"> %>' />




Download Sample Code

Tags:

16 comments so far...

Re: Row level validation in a gridview

Very usefull, yet very simple.

By Daniel C. on   Tue, 19 Aug 2008 13:27:54 GMT

Re: Row level validation in a gridview

Cheers, very neat.

By b on   Wed, 04 Nov 2009 09:27:03 GMT

<a href="http://www.shoes-luxury.com" title="Christian Louboutin shoes">Christian Louboutin shoes</a> lover worldwide favorite site!Shop all style discount <a href="http://www.shoes-luxury.com" title="Chri

Christian Louboutin shoes lover worldwide favorite site!Shop all style discount Christian Louboutin and save up to 70% Off Select Christian Louboutin sale!Order now!

By Christian Louboutin shoes on   Wed, 12 May 2010 09:12:26 GMT

Re: Row level validation in a gridview

Buy replica watches or replica watches and [url=http://www.watchesday.com]replica watches[/url] on sale.

By replica watches on   Mon, 31 May 2010 05:56:04 GMT

<a href="http://wendysreplica.com/blog/">designer handbags reviews</a>

designer handbags reviewsdesigner handbags reviewsdesigner handbags reviews

By <a href="http://wendysreplica.com/blog/&qu on   Fri, 18 Jun 2010 02:48:35 GMT

Re: Row level validation in a gridview

Everybody must be know some famous brands of the world,just like the Handbags:Hermes handbags, Chanel Handbags, shoes about Christian Louboutin, Christian Louboutin, Louis Vuitton, Chanel.Every brand will make you more charming.But do you think of that some day you can get it to your own,that's it,here has the proof that this is the truth.You will be shock by it.

By cao on   Thu, 08 Jul 2010 03:45:40 GMT

<a href="http://www.coachoutletmalls.com/">Coach outlet</a> <a href="http://www.coachoutletmalls.com/">coach bags outlet</a> <a href="http://www.coachoutletmalls.com/">coach outlet store</a&

Coach outlet
coach bags outlet
coach outlet store
coach outlet online
gucci handbags outlet
gucci outlet
gucci handbags
gucci handbags
gucci handbags outlet
gucci outlet
This article is written by zocy004 on 2010-7-15
http://www.coachoutletmalls.com

By coach outlet on   Thu, 15 Jul 2010 06:26:45 GMT

Re: Row level validation in a gridview

In 130 countries around the world, each piece of Omega was sold by first-class dealers is the young generation's ideal Omega Watches in modern times.as well as pursue the Omega Watches sale . In American, cheap Omega Watches is the most popular and dicount Omega Watches and the best Omega replica Watches. The combination of Omega Watch and the Omega Watch sale make Fake cheap Omega Watch the leader in the watchesindustry. dicount Omega Watch in moden times is very popular and 张亚楠测试 must give you a new life! 张亚楠测试html

By hermes on   Sat, 17 Jul 2010 08:57:49 GMT

Re: Row level validation in a gridview

Do youreplica handbags long for the bally handbagsfeeling you get from balenciaga handbagsbuying top quality fashions? Do youprada handbags stay on top of gianni versace handbagsthe latest trends and wonderRolex watches what’s Bally handbagsTag Heuer watches going to be next on the designerU-boat watches runways ofA.Lange & Sohne watches Milan and Paris? Or balenciaga replica handbagsare you a function-driven coach replica handbagsconsumer, looking for the best dior handbagsquality in classicLongines for sale styles that will Louis Vuitton for salelast for years? Ferrari for saleWhether you’re seeking practical and proven, or Glashutte for saletrendy andreplica Alain Silberstein hip, handbags arereplica Concord a great way to express replica Franck Muller your style without blowing your budget!





By replcia watches on   Mon, 19 Jul 2010 00:28:51 GMT

Re: Row level validation in a gridview

Do youreplica handbags long for the bally handbagsfeeling you get from balenciaga handbagsbuying top quality fashions? Do youprada handbags stay on top of gianni versace handbagsthe latest trends and wonderRolex watches what’s Bally handbagsTag Heuer watches going to be next on the designerU-boat watches runways ofA.Lange & Sohne watches Milan and Paris? Or balenciaga replica handbagsare you a function-driven coach replica handbagsconsumer, looking for the best dior handbagsquality in classicLongines for sale styles that will Louis Vuitton for salelast for years? Ferrari for saleWhether you’re seeking practical and proven, or Glashutte for saletrendy andreplica Alain Silberstein hip, handbags arereplica Concord a great way to express replica Franck Muller your style without blowing your budget!





By replcia watches on   Mon, 19 Jul 2010 00:29:59 GMT

Re: Row level validation in a gridview

o me tiffany jewelry replica to correct people's thinking and replica watches uk explain why. I didn't want charleston watch the last memory with the tiffany and co jewelry public to be just that. replica chanel jewelry There's got to be an replica audemars piguet understanding now of him as tiffany replicas a human being, not a Audemars Piguet Canape celluloid fantasy, with faults and gucci replica watches his own demons, and for Audemars Piguet Canape people to understand why he jewellery pendants was like this."
Anderson, who is corum admiral's cup also an aut

By asd on   Fri, 23 Jul 2010 08:25:14 GMT

Re: Row level validation in a gridview

Now lots of people buy adult sex product to improve sex life [url=http://www.dailysexnlove.com/]open bust babydoll[/url],we supply all kinds of adult sex product [url=http://www.dailysexnlove.com/]Strap on dildos[/url],because we are manufacture and have our factory [url=http://www.dailysexnlove.com/]Finger vibrators[/url],our product are all safe and wholesale [url=http://www.dailysexnlove.com/]wife babydoll[/url],welcome to visit our store [url=http://www.dailysexnlove.com/]stocking online[/url],all kinds of adult sex product for female and male [url=http://www.dailysexnlove.com/]baby doll nighties[/url], you will buy your love sex product from our store [url=http://www.dailysexnlove.com/]women stocking[/url],adult sex product will greatly improve the quality of your sex life [url=http://www.dailysexnlove.com/]babydoll costumes[/url],sex life is very important [url=http://www.dailysexnlove.com/]Wholesale Long Stocking[/url],sex life is harmonious [url=http://www.dailysexnlove.com/]pijamas[/url],the life is happies [url=http://www.dailysexnlove.com/]high stocking[/url],you can introduce your family and friend to visit our store [url=http://www.dailysexnlove.com/]Long Lady Stocking[/url],best wish to every happy family [url=http://www.dailysexnlove.com/]halter babydoll plus size[/url]

By black babydoll on   Sat, 24 Jul 2010 08:11:39 GMT

cheap replica handbags hot sale

GLT07a28zhou

http://www.top-replica-handbags.net Replica Handbags
http://www.top-replica-handbags.net Replica Purses
http://www.top-replica-handbags.net Designer Replica handbags
http://www.top-replica-handbags.net Designer bags
http://www.tiffanyjewelry9.com Tiffany Jewelry
http://www.tiffanyjewelry9.com Replica tiffany
http://www.tiffanyjewelry9.com wholesale crystal

http://www.top-replica-handbags.net/Louis-vuitton-handbags.html Louis Vuitton Handbags
http://www.top-replica-handbags.net/LOUIS-VUITTON_1.html Louis Vuitton Replica Handbags
http://www.top-replica-handbags.net/GUCCI_3.html Gucci handbags
http://www.top-replica-handbags.net/PRADA_4.html Prada Handbags
http://www.top-replica-handbags.net/HERMES_28.html Hermes Handbags
http://www.top-replica-handbags.net/BURBERRY_88.html BURBERRY Handbags
http://www.top-replica-handbags.net/DIOR_105.html Dior Handbags
http://www.top-replica-handbags.net/WALLETS_92.html Replica Wallets
http://www.top-replica-handbags.net/WALLETS_Louis-Vuitton-Wallets_137.html Louis Vuitton Wallets
http://www.top-replica-handbags.net/WALLETS_Gucci-Wallets_139.html Gucci Wallets
http://www.top-replica-handbags.net/WALLETS_Hermes-Wallets_138.html Hermes Wallets
http://www.top-replica-handbags.net/WALLETS_Burberry-Wallets_145.html Burberry Wallets
http://www.top-replica-handbags.net/SUNGLASSES_197.html Replica Sunglasses
http://www.top-replica-handbags.net/SUNGLASSES_197.html Designer Replica Sunglasses
http://www.top-replica-handbags.net/BELTS_Hermes-Belts_134.html Hermes Belts
http://www.top-replica-handbags.net/BELTS_Louis-Vuitton-Belts_135.html Louis Vuitton Belts
http://www.top-replica-handbags.net/BELTS_Gucci-Belts_136.html Gucci Belts
http://www.tiffanyjewelry9.com/Tiffany-Jewelry_43.html tiffany jewelry
http://www.tiffanyjewelry9.com/Hermes-Jewelry_86.html Hermes Jewelry
http://www.tiffanyjewelry9.com/Gucci-Jewelry_58.html Gucci Jewelry
http://www.tiffanyjewelry9.com/DIOR-Jewelry_83.html Dior Jewelry
http://www.tiffanyjewelry9.com/Bvlgari-Jewelry_64.html Bvlgari Jewelry
http://www.tiffanyjewelry9.com/Cartier-Jewelry_72.html Cartier Jewelry
http://www.tiffanyjewelry9.com/Links-Jewelry_79.html Links Jewelry
http://www.tiffanyjewelry9.com/D-G-Jewelry_81.html D&G Jewelry
http://www.tiffanyjewelry9.com/Chic-Jewelry_121.html Chic Jewelry
http://www.weddingdressesboxes.com Wedding Dresses
http://www.exact-handbags.com replica purses

By replica-handbags on   Wed, 28 Jul 2010 05:48:16 GMT

Your name:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment    Cancel  
 
 
     
     
 
   Archives Minimize
 
 
     
     
 
   Search Blog Minimize