473,626 Members | 3,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGrid Button Validation Problem

the Edit, Update, Cancel, and Delete buttons in my datagrid are causing
validation elsewhere on the page. I want to specify that these buttons
should not cause validation but they have no design time property of
causevalidation .

How can I keep them from causing validation?

Thanks,
T
Nov 20 '05 #1
5 2046

In ItemDataBound or ItemCreated event, you can get Edit button reference by

LinkButton editBtn = (LinkButton)e.I tem.Cells[edit_column_ind ex].Controls[0];
editBtn.CausesV alidation = false;

But in order to get refernce of Update / Canel button, you need to do it in
EditCommand event.
DataGrid.EditIt emIndex = e.Item.ItemInde x;
DataGrid.DataSo urce = dataObj;
DataGrid.DataBi nd();
// up to now the e.Item.ItemInde x row of DataGrid becomes edit state. But
e.Item is still in normal state. So you need get Update button from datagrid
LinkButton updateBtn =
(LinkButton)thi s.DataGrid.Item s[e.Item.ItemInde x].Cells[button_col_inde x].Controls[0];
// then set its CausesValidatio n
updateBtn.Cause sValidation = true/false;

HTH

Elton Wang

"Tina" wrote:
the Edit, Update, Cancel, and Delete buttons in my datagrid are causing
validation elsewhere on the page. I want to specify that these buttons
should not cause validation but they have no design time property of
causevalidation .

How can I keep them from causing validation?

Thanks,
T

Nov 20 '05 #2
Elton,
Im using vb..

Actually only the Update button causes validation as the others already are
set to not cause validation. My problem, however, is
that in the EditCommand event
myDataGrid.Item s(e.Item.ItemIn dex).Cells(0).C ontrols(0) has
in it the Edit button and
myDataGrid.Item s(e.Item.ItemIn dex).Cells(1).C ontrols(0) has the Cancel
button in it. Those buttons are already set to CausesValidatio n = false.

I have fished everywhere but I can't find the Update button!

Still looking,
T

"Elton W" <El****@discuss ions.microsoft. com> wrote in message
news:CF******** *************** ***********@mic rosoft.com...

In ItemDataBound or ItemCreated event, you can get Edit button reference
by

LinkButton editBtn =
(LinkButton)e.I tem.Cells[edit_column_ind ex].Controls[0];
editBtn.CausesV alidation = false;

But in order to get refernce of Update / Canel button, you need to do it
in
EditCommand event.
DataGrid.EditIt emIndex = e.Item.ItemInde x;
DataGrid.DataSo urce = dataObj;
DataGrid.DataBi nd();
// up to now the e.Item.ItemInde x row of DataGrid becomes edit state. But
e.Item is still in normal state. So you need get Update button from
datagrid
LinkButton updateBtn =
(LinkButton)thi s.DataGrid.Item s[e.Item.ItemInde x].Cells[button_col_inde x].Controls[0];
// then set its CausesValidatio n
updateBtn.Cause sValidation = true/false;

HTH

Elton Wang

"Tina" wrote:
the Edit, Update, Cancel, and Delete buttons in my datagrid are causing
validation elsewhere on the page. I want to specify that these buttons
should not cause validation but they have no design time property of
causevalidation .

How can I keep them from causing validation?

Thanks,
T

Nov 20 '05 #3
If you don't have an insert button you can just set your Delete button to
DelBtn.CausesVa lidation = false;
Patrick

"Tina" <ti**********@n ospammeexcite.c om> wrote in message
news:uI******** ******@TK2MSFTN GP10.phx.gbl...
the Edit, Update, Cancel, and Delete buttons in my datagrid are causing
validation elsewhere on the page. I want to specify that these buttons
should not cause validation but they have no design time property of
causevalidation .

How can I keep them from causing validation?

Thanks,
T

Nov 20 '05 #4
If you are using EditCommandColu mn in first column, you can get Update and
Cancel buttons by following code in EditCommand event.

' Update button normally is in the first control
Dim updateBtn As LinkButton =
CType(myDataGri d.Items(e.Item. ItemIndex).Cell s(0).Controls(0 ), LinkButton)

'cancel button in 3rd control (2nd control is a Literal control, like space,
or you can try cast 2nd control to button)
Dim cancelBtn As LinkButton =
CType(myDataGri d.Items(e.Item. ItemIndex).Cell s(0).Controls(2 ), LinkButton)

HTH

Elton
"Tina" wrote:
Elton,
Im using vb..

Actually only the Update button causes validation as the others already are
set to not cause validation. My problem, however, is
that in the EditCommand event
myDataGrid.Item s(e.Item.ItemIn dex).Cells(0).C ontrols(0) has
in it the Edit button and
myDataGrid.Item s(e.Item.ItemIn dex).Cells(1).C ontrols(0) has the Cancel
button in it. Those buttons are already set to CausesValidatio n = false.

I have fished everywhere but I can't find the Update button!

Still looking,
T

"Elton W" <El****@discuss ions.microsoft. com> wrote in message
news:CF******** *************** ***********@mic rosoft.com...

In ItemDataBound or ItemCreated event, you can get Edit button reference
by

LinkButton editBtn =
(LinkButton)e.I tem.Cells[edit_column_ind ex].Controls[0];
editBtn.CausesV alidation = false;

But in order to get refernce of Update / Canel button, you need to do it
in
EditCommand event.
DataGrid.EditIt emIndex = e.Item.ItemInde x;
DataGrid.DataSo urce = dataObj;
DataGrid.DataBi nd();
// up to now the e.Item.ItemInde x row of DataGrid becomes edit state. But
e.Item is still in normal state. So you need get Update button from
datagrid
LinkButton updateBtn =
(LinkButton)thi s.DataGrid.Item s[e.Item.ItemInde x].Cells[button_col_inde x].Controls[0];
// then set its CausesValidatio n
updateBtn.Cause sValidation = true/false;

HTH

Elton Wang

"Tina" wrote:
the Edit, Update, Cancel, and Delete buttons in my datagrid are causing
validation elsewhere on the page. I want to specify that these buttons
should not cause validation but they have no design time property of
causevalidation .

How can I keep them from causing validation?

Thanks,
T


Nov 20 '05 #5
Thanks for getting me started on this problem. The way it worked out for me
was a little different than what your examples show....

in the EditCommand event I can get e.item.iteminde x which tells me which row
is being edited (of course) but I could not find the Update button because
in the Edititem event it's not there yet. So I saved the line number
then...

in the ItemDataBound event, which gets visited once for every line, if it's
my line number, then the update button can be found and that is where I was
able to set CausesValidatio n to false.

So, it works now and fortunitely I don't have any validators in the
itemtemplates so I don't need for that button to validate. The permanent
solution, I think, is that there should be a smaller scope for validation
than the page.

Anyway, thanks for the help.
T

"Elton W" <El****@discuss ions.microsoft. com> wrote in message
news:74******** *************** ***********@mic rosoft.com...
If you are using EditCommandColu mn in first column, you can get Update and
Cancel buttons by following code in EditCommand event.

' Update button normally is in the first control
Dim updateBtn As LinkButton =
CType(myDataGri d.Items(e.Item. ItemIndex).Cell s(0).Controls(0 ), LinkButton)

'cancel button in 3rd control (2nd control is a Literal control, like
space,
or you can try cast 2nd control to button)
Dim cancelBtn As LinkButton =
CType(myDataGri d.Items(e.Item. ItemIndex).Cell s(0).Controls(2 ), LinkButton)

HTH

Elton
"Tina" wrote:
Elton,
Im using vb..

Actually only the Update button causes validation as the others already
are
set to not cause validation. My problem, however, is
that in the EditCommand event
myDataGrid.Item s(e.Item.ItemIn dex).Cells(0).C ontrols(0) has
in it the Edit button and
myDataGrid.Item s(e.Item.ItemIn dex).Cells(1).C ontrols(0) has the Cancel
button in it. Those buttons are already set to CausesValidatio n = false.

I have fished everywhere but I can't find the Update button!

Still looking,
T

"Elton W" <El****@discuss ions.microsoft. com> wrote in message
news:CF******** *************** ***********@mic rosoft.com...
>
> In ItemDataBound or ItemCreated event, you can get Edit button
> reference
> by
>
> LinkButton editBtn =
> (LinkButton)e.I tem.Cells[edit_column_ind ex].Controls[0];
> editBtn.CausesV alidation = false;
>
> But in order to get refernce of Update / Canel button, you need to do
> it
> in
> EditCommand event.
>
>
> DataGrid.EditIt emIndex = e.Item.ItemInde x;
> DataGrid.DataSo urce = dataObj;
> DataGrid.DataBi nd();
> // up to now the e.Item.ItemInde x row of DataGrid becomes edit state.
> But
> e.Item is still in normal state. So you need get Update button from
> datagrid
> LinkButton updateBtn =
> (LinkButton)thi s.DataGrid.Item s[e.Item.ItemInde x].Cells[button_col_inde x].Controls[0];
> // then set its CausesValidatio n
> updateBtn.Cause sValidation = true/false;
>
> HTH
>
> Elton Wang
>
> "Tina" wrote:
>
>> the Edit, Update, Cancel, and Delete buttons in my datagrid are
>> causing
>> validation elsewhere on the page. I want to specify that these
>> buttons
>> should not cause validation but they have no design time property of
>> causevalidation .
>>
>> How can I keep them from causing validation?
>>
>> Thanks,
>> T
>>
>>
>>


Nov 20 '05 #6

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

Similar topics

14
2079
by: Jack Kaufmann | last post by:
I am trying to verify a datagrid in which there must be an entry in both columns of any new row, and those values must be greater than the corresponding values in the previous row. It is pretty simple to verify the cell the user starts in by invoking a verifying event for the underlying textbox in that cell, but what I would like to do is to change the focus to the other column in the new row if it has not been filled in. If in handling...
2
423
by: Sebastian | last post by:
Hi, I have datagrid. In its footer there is editbox to add new item. All is cool. Datagrids 'Delete' button has CausesValidation set to false and all is great. But the problem is in 'Process' page button. ('Process' button saves all data on the page to database). When I click 'Process' button datagrids footer textbox are being validated and becouse they are empty error message pops up. I don't want to set CausesValidation to false for...
4
2281
by: z. f. | last post by:
Hi, I'm having an aspx page with a server form. i have a grid with a delete button and below the grid, another area with inputs for inserting new values and an "add" button for submiting the lower area of the form. on the lower area i have validators for validating input.
4
2068
by: Luis Esteban Valencia | last post by:
I have a asp.net page (C#), with a datagrid. I use template for all columns, and have <asp:requiredfieldvalidator> in with one of the textboxes, to make sure it's filled in. However, this validation is not firing, even when I leave the field empty. Below please find the code: <%@ Page Language="C#" Debug="true" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %>
5
3239
by: Chris | last post by:
Based upon some prevoius postings on what to do for adding a 'add' row to a datagrid I utilize the footer to create the 'add' row. The only issue is that I have it sharing the 'UpDate_Command' and I use an argument to difference between an 'edit' vs. and 'add. But since I have field validation on both 'footer' and 'edit' columns I can't submit my edits since the footer validation kicks in.If I take the validation off then the both work fine...
4
3473
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 Edit Commmand are getting fired properly. The One difference I have seen is that in the task bar ..on hovering on the link the javascript for the update link seems different. I dont know if it makes sense..
4
2965
by: David Colliver | last post by:
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
1
2375
by: Kris | last post by:
Hi, I have a DataGrid where in each row has couple of text boxes and an update button. Each row is dynamically generated as the number of rows are not known ahead of time. When the user clicks the update button, I do a postback to capture the data entered. However I dont want to do a postback when the textboxes are empty. How do I prevent this using Clientside validation? This is a common problem and if it has been beaten to death, please...
1
1736
by: mike | last post by:
I posted before and got the reply below, which really doesn't help me at all. I really didn't understand what the responder was talking about I'd like someone who is a microsoft expert to help me with some specifics on this problem: I have to do some specific data verification before saving a row or group of rows to the database (the data validation in the datagrid really doesn't help all that
0
8196
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8701
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7192
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6122
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2623
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1507
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.