Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Adding Validation via OnItemDataBound event (ASP.NET 2.0)

Reply
Thread Tools

Adding Validation via OnItemDataBound event (ASP.NET 2.0)

 
 
rmccinc@hotmail.com
Guest
Posts: n/a
 
      09-28-2005
OK, I am running into some issues that I cant figure out a work-around.
I am not going to post code cause I figured out WHY my issue is
happening:

-I have a datagrid, and a button that fires a click event.

-The Datagrids onitemdatabound event dynamically creates validation
controls per values from other columns in the datagrid, one of those
controls is a textbox and it is the ControlToValidate of the validation
control.

ie - Basically, think of a shopping cart with a quantity textbox and
another NOT visible column for inventory. During onitemdatabound I
check the inventory (tempInventory = e.Item.Cells(1).Text) and create
the necessary validation for Qty.

Everything works great with client side validation, the problem starts
when I attempt to process validation server side.

When my button with the click event is fired, Page.IsValid is always
true. BUT, when I move the validation control creation to the
OnItemCreated event, it all works fine.

My problem is that the validation relies on data, which OnItemDataBound
has not fired yet for that item.

Any ideas? In theory, I am thinking of creating the validation fully at
itemCreated, then disable and change validator properties at the
itemdatabound event if applicable???? I don't know if that will even
work.

 
Reply With Quote
 
 
 
 
Brock Allen
Guest
Posts: n/a
 
      09-29-2005
I can't follow exactly what's going on in your app, but as with any server
controls that are dynamically created, you need to recreate them upon postback.
I suspect that's why it's working if you do it in ItemDataBound but not when
you remove it from that event.

-Brock
DevelopMentor
http://staff.develop.com/ballen

> OK, I am running into some issues that I cant figure out a
> work-around. I am not going to post code cause I figured out WHY my
> issue is happening:
>
> -I have a datagrid, and a button that fires a click event.
>
> -The Datagrids onitemdatabound event dynamically creates validation
> controls per values from other columns in the datagrid, one of those
> controls is a textbox and it is the ControlToValidate of the
> validation control.
>
> ie - Basically, think of a shopping cart with a quantity textbox and
> another NOT visible column for inventory. During onitemdatabound I
> check the inventory (tempInventory = e.Item.Cells(1).Text) and create
> the necessary validation for Qty.
>
> Everything works great with client side validation, the problem starts
> when I attempt to process validation server side.
>
> When my button with the click event is fired, Page.IsValid is always
> true. BUT, when I move the validation control creation to the
> OnItemCreated event, it all works fine.
>
> My problem is that the validation relies on data, which
> OnItemDataBound has not fired yet for that item.
>
> Any ideas? In theory, I am thinking of creating the validation fully
> at itemCreated, then disable and change validator properties at the
> itemdatabound event if applicable???? I don't know if that will even
> work.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Catch the OnItemDataBound event on ComponentArt Menu Luigi ASP .Net 0 03-06-2008 01:57 PM
onItemDataBound event not firing on first go thru since moving to .net 2.0 TS ASP .Net 14 12-12-2006 08:33 PM
VB.NET code troubleshooting (CommandArgument property during OnItemDataBound event) jason ASP .Net 2 06-14-2005 12:35 PM
unable to render nested datalist when invoking the OnItemDataBound event - please help! Joey ASP .Net Web Controls 0 09-23-2004 09:03 AM
OnItemDataBound event not firing GOKU24 ASP .Net Building Controls 0 07-08-2003 08:05 PM



Advertisments