Reputation: 5409
I'm facing a problem with one of my pages. I have a FormView control on the page that I use to enter new rows into a database table, and a GridView control on the same page to update/delete rows from the same database table.
The FormView control has validators on it to validate any input being thrown at the database, and it seems to interfere with the GridView when I try to edit a row. When I try to save the edit, the validation control on the FormView gets fired and an error comes up because the textbox input is blank, so the GridView cannot save the modified table data.
Perhaps a visible example will help:
I had an idea where I encase these controls in different forms, hoping that the submit of one form won't fire anything in the other but then I got an error saying I can't have more than one form on the page with runat="server"
, which as far as I can tell is required.
How can I get around this?
Thanks.
Upvotes: 2
Views: 1150
Reputation: 43280
What I did is I had two forms coded as postback to the page and parsed out the postback variables in Page.Load myself. Weird? Yes. Works? Yes.
Upvotes: 1
Reputation: 7591
Yes, this is a known limitation (feature?) of webforms. You can only have 1 form with a runat="server"
tag.
In your scenario you can use ValidationGroup
names to group validation together so only "like" validation is executed when a control of the same validation is triggered.
Upvotes: 1
Reputation: 460128
You can only have one Form
.
Use different ValidationGroups
for your FormView
and GridView
instead.
http://msdn.microsoft.com/en-us/library/ms227424(v=vs.100).aspx
Upvotes: 2