472,972 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,972 software developers and data experts.

Update button in datagrid causing validation elsewhere on page

Hi all,

I am having a slight problem that hopefully, someone can help me fix.

I have a form on a page. Many items on the form have validation controls
attached.
Also on this form are linkbuttons which must not cause validation. I have
found a setting "causeValidation" to disable the validation.

Also on the page, I have a datagrid that I will edit lines on. I can click
edit and cancel without enforced validation, however, if I click Update, the
validation comes up.

I have tried to put a causesValidation="false" in the linkbutton column on
the datagrid but to no avail.

When I hover over the Update link, I have...
javascript:{if {typeod(Page_ClientValidate) != 'function' ||
Page_ClientValidate()) __doPostback...

in the status bar.

How can I override the Update link to prevent the validation from happening?

Also, if I was to limit just the Update to the datagrid text boxes, how
would I validate those?

A third Q... when in edit mode of the datagrid, how can I use a DropDownList
instead of a text box?

Thanks.

Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available
Nov 19 '05 #1
4 2931
Hi David,

ASP.NET 2.0 will solve it with the introduction of "validation groups". It
allows you to assign a group name to the submit control and the validators
it fires. My Professional Validation And More product
(http://www.peterblum.com/vam/home.aspx) supports validation groups (its
actually more powerful than the ASP.NET 2.0 version although they look very
similar.)

In ASP.NET 1.x, the normal way to get the same behavior is to turn off
client-side validation on the submit button. This would work for your
linkbutton:
- Set CausesValidation=false
- In the Click post back event method, call each validator's Validate()
method that applies to this button. Then test IsValid is true on all of the
same validators. Proceed if all are true.

This is harder with a DataGrid because the Update button's CausesValidation
property is hidden from you and is always true.

I encourage you to download the trial version of Professional Validation And
More to explore how it can help you. Its a much bigger system than just a
fix to this problem. It has 45 controls and many new ideas for validation
including client-side support of validation on many more browsers like
FireFox and Safari.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"David Colliver" <Da***********@discussions.microsoft.com> wrote in message
news:C8**********************************@microsof t.com...
Hi all,

I am having a slight problem that hopefully, someone can help me fix.

I have a form on a page. Many items on the form have validation controls
attached.
Also on this form are linkbuttons which must not cause validation. I have
found a setting "causeValidation" to disable the validation.

Also on the page, I have a datagrid that I will edit lines on. I can click
edit and cancel without enforced validation, however, if I click Update,
the
validation comes up.

I have tried to put a causesValidation="false" in the linkbutton column on
the datagrid but to no avail.

When I hover over the Update link, I have...
javascript:{if {typeod(Page_ClientValidate) != 'function' ||
Page_ClientValidate()) __doPostback...

in the status bar.

How can I override the Update link to prevent the validation from
happening?

Also, if I was to limit just the Update to the datagrid text boxes, how
would I validate those?

A third Q... when in edit mode of the datagrid, how can I use a
DropDownList
instead of a text box?

Thanks.

Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available

Nov 19 '05 #2
Hi David,

As you mention, causeValidation can disable the validation. You can set
Update Button's causeValidation in datagrid_EditCommand event:
datagrid.EditItemIndex = e.Item.ItemIndex;
datagrid.DataBind();

LinkButton updateBtn =
(LinkButton)datagrid.Items[e.Item.ItemIndex].Controls[0];
updateBtn.CausesValidation = false;

HTH

Elton Wang
el********@hotmail.com

"David Colliver" wrote:
Hi all,

I am having a slight problem that hopefully, someone can help me fix.

I have a form on a page. Many items on the form have validation controls
attached.
Also on this form are linkbuttons which must not cause validation. I have
found a setting "causeValidation" to disable the validation.

Also on the page, I have a datagrid that I will edit lines on. I can click
edit and cancel without enforced validation, however, if I click Update, the
validation comes up.

I have tried to put a causesValidation="false" in the linkbutton column on
the datagrid but to no avail.

When I hover over the Update link, I have...
javascript:{if {typeod(Page_ClientValidate) != 'function' ||
Page_ClientValidate()) __doPostback...

in the status bar.

How can I override the Update link to prevent the validation from happening?

Also, if I was to limit just the Update to the datagrid text boxes, how
would I validate those?

A third Q... when in edit mode of the datagrid, how can I use a DropDownList
instead of a text box?

Thanks.

Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available

Nov 19 '05 #3
Hi Elton,

Thank you.

However, I am having a problem...

I have exactly the code you have suggested (with object names changed as
neccessary) but I am getting...

System.ArgumentOutOfRangeException: Index was out of range. Must be
non-negative and less than the size of the collection. Parameter name: index

My code...

private void SecondaryEdEducationDataGrid_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
SecondaryEdEducationDataGrid.EditItemIndex = e.Item.ItemIndex;
SecondaryEdEducationDataGrid.DataBind();
Trace.Warn("ItemIndex", e.Item.ItemIndex.ToString());
LinkButton updateBtn =
(LinkButton)SecondaryEdEducationDataGrid.Items[e.Item.ItemIndex].Controls[0];
updateBtn.CausesValidation = false;
}

The line that is being pointed to is the "LinkButton updateBtn" line.

I understand what you are pointing me at, and it was an area that I had not
considered.

Thanks.
Regards,
Dave Colliver.
http://www.DerbyFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available
"Elton W" wrote:
Hi David,

As you mention, causeValidation can disable the validation. You can set
Update Button's causeValidation in datagrid_EditCommand event:
datagrid.EditItemIndex = e.Item.ItemIndex;
datagrid.DataBind();

LinkButton updateBtn =
(LinkButton)datagrid.Items[e.Item.ItemIndex].Controls[0];
updateBtn.CausesValidation = false;

HTH

Elton Wang
el********@hotmail.com

"David Colliver" wrote:
Hi all,

I am having a slight problem that hopefully, someone can help me fix.

I have a form on a page. Many items on the form have validation controls
attached.
Also on this form are linkbuttons which must not cause validation. I have
found a setting "causeValidation" to disable the validation.

Also on the page, I have a datagrid that I will edit lines on. I can click
edit and cancel without enforced validation, however, if I click Update, the
validation comes up.

I have tried to put a causesValidation="false" in the linkbutton column on
the datagrid but to no avail.

When I hover over the Update link, I have...
javascript:{if {typeod(Page_ClientValidate) != 'function' ||
Page_ClientValidate()) __doPostback...

in the status bar.

How can I override the Update link to prevent the validation from happening?

Also, if I was to limit just the Update to the datagrid text boxes, how
would I validate those?

A third Q... when in edit mode of the datagrid, how can I use a DropDownList
instead of a text box?

Thanks.

Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available

Nov 19 '05 #4
Sorted now...

It should be...

LinkButton updateBtn =
(LinkButton)datagrid.Items[e.Item.ItemIndex].Controls[0].Controls[0];

Notice the second .Controls[0] ?

Regards,
Dave Colliver.
http://www.ChesterfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available
"David Colliver" wrote:
Hi Elton,

Thank you.

However, I am having a problem...

I have exactly the code you have suggested (with object names changed as
neccessary) but I am getting...

System.ArgumentOutOfRangeException: Index was out of range. Must be
non-negative and less than the size of the collection. Parameter name: index

My code...

private void SecondaryEdEducationDataGrid_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
SecondaryEdEducationDataGrid.EditItemIndex = e.Item.ItemIndex;
SecondaryEdEducationDataGrid.DataBind();
Trace.Warn("ItemIndex", e.Item.ItemIndex.ToString());
LinkButton updateBtn =
(LinkButton)SecondaryEdEducationDataGrid.Items[e.Item.ItemIndex].Controls[0];
updateBtn.CausesValidation = false;
}

The line that is being pointed to is the "LinkButton updateBtn" line.

I understand what you are pointing me at, and it was an area that I had not
considered.

Thanks.
Regards,
Dave Colliver.
http://www.DerbyFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available
"Elton W" wrote:
Hi David,

As you mention, causeValidation can disable the validation. You can set
Update Button's causeValidation in datagrid_EditCommand event:
datagrid.EditItemIndex = e.Item.ItemIndex;
datagrid.DataBind();

LinkButton updateBtn =
(LinkButton)datagrid.Items[e.Item.ItemIndex].Controls[0];
updateBtn.CausesValidation = false;

HTH

Elton Wang
el********@hotmail.com

"David Colliver" wrote:
Hi all,

I am having a slight problem that hopefully, someone can help me fix.

I have a form on a page. Many items on the form have validation controls
attached.
Also on this form are linkbuttons which must not cause validation. I have
found a setting "causeValidation" to disable the validation.

Also on the page, I have a datagrid that I will edit lines on. I can click
edit and cancel without enforced validation, however, if I click Update, the
validation comes up.

I have tried to put a causesValidation="false" in the linkbutton column on
the datagrid but to no avail.

When I hover over the Update link, I have...
javascript:{if {typeod(Page_ClientValidate) != 'function' ||
Page_ClientValidate()) __doPostback...

in the status bar.

How can I override the Update link to prevent the validation from happening?

Also, if I was to limit just the Update to the datagrid text boxes, how
would I validate those?

A third Q... when in edit mode of the datagrid, how can I use a DropDownList
instead of a text box?

Thanks.

Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available

Nov 19 '05 #5

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

Similar topics

2
by: Manish | last post by:
Hey folks I am having a weird problem in ASP .Net. My page is in C#. I have a datagrid, which populates based on selection in drop down box on ASP page. This datagrid has template textbox colum in...
3
by: John Blair | last post by:
Hi, I have validators outside of a datagrid (for adding a new grid row) - however when i click "edit" column and then the "update" column of a grid row that has been edited - my other...
4
by: siaj | last post by:
Hello All, If some one has faced a similar issue.. My datagrid Update command is not getting fired in fact it seems that the no event fires on clicking the update link. Although the cancel and the...
25
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
13
by: Lyners | last post by:
I have a web page writen in ASP.NET that contains some javascript so that when a user presses a button, or edits a certain field in a datagrid, another cell in the datagrid is filled with a value....
0
by: Erik | last post by:
Why isn't my update method getting called? Pasted below is an aspx from a 1.1 application I'm working on. It has two textboxes and a button for inserting data into the database, and a datagrid...
1
by: geeteshss | last post by:
Dear all, actually i spent a whole month on the R&D of datagrid edit ,update,cancel events but recently my guide told me to make it user friendly because no user would like to go on searching rows...
11
by: SAL | last post by:
Hello, I have a Gridview control (.net 2.0) that I'm having trouble getting the Update button to fire any kind of event or preforming the update. The datatable is based on a join so I don't know...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.