Hi,
i stated that this is an advanced question because i have a post from few
days ago that i received answers to with suggestions that looked good but
did not work, so please if you post a reply make sure your suggestion
actually works.
like a <asp:button> control have a CausesValidation property that allows it
to POST a button command event to the server without causing the page to
make validation on form inputs, i need to get the same functionallity to an
<asp:button> culomn with a delete command.
i tried to use the OnItemCreated event of the datagrid, to add this
property, but perhaps becuase the button inside the grid is actually an
array of buttons, setting the property had no effect.
also tried to make an <TemplateItem> with the button inside, but again
setting the property had no effect and the form did passed the validation
check.
please advise, but don't just throw "why don't you try this", and as it did
last time, it did not work.
i'm gessing there must be a way (even use javascript or something) - to make
a command from the grid row without passing the form validation.
TIA, z. 4 1968
Hi z.f:
Perhaps you could post some code to look at. I've tried this with an
ItemTemplate like so:
<form id="Form1" method="post" runat="server">
<asp:DataGrid id="DataGrid1" runat="server"
AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="au_id" HeaderText="au_id"/>
<asp:TemplateColumn HeaderText="test">
<ItemTemplate>
<asp:Button Runat="server" ID="button1"
CausesValidation="False" />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
<asp:TextBox Runat="server" ID="textbox1" />
<asp:RequiredFieldValidator Runat="server"
ID="requiredFieldValidator"
ControlToValidate="textbox1"
ErrorMessage="You screwed up" />
<asp:Button Runat="server" ID="mainbutton" />
</form>
In this case pressing a button in the DataGrid does not cause
validation.
--
Scott http://www.OdeToCode.com
On Thu, 24 Jun 2004 11:20:03 +0200, "z. f."
<zi**@info-scopeREMSPAM.co.il> wrote: Hi,
i stated that this is an advanced question because i have a post from few days ago that i received answers to with suggestions that looked good but did not work, so please if you post a reply make sure your suggestion actually works.
like a <asp:button> control have a CausesValidation property that allows it to POST a button command event to the server without causing the page to make validation on form inputs, i need to get the same functionallity to an <asp:button> culomn with a delete command.
i tried to use the OnItemCreated event of the datagrid, to add this property, but perhaps becuase the button inside the grid is actually an array of buttons, setting the property had no effect.
also tried to make an <TemplateItem> with the button inside, but again setting the property had no effect and the form did passed the validation check.
please advise, but don't just throw "why don't you try this", and as it did last time, it did not work.
i'm gessing there must be a way (even use javascript or something) - to make a command from the grid row without passing the form validation.
TIA, z.
i'll check it up ,
for now i managed to do with overriding the Validate method of the page
object and only if i want to, i call
MyBase.Validate()
but i will try your code as soon as i'll make another grid with delete
buttons etc', that should not make validation of other operation that the
page can do.
question: the button inside the <asp:TemplateColumn HeaderText="test">, how
it "knows" which id it acts for, do i need to write code in the
OnItemCreated , or it can handle a grid command like delete?
thanx.
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:gj********************************@4ax.com... Hi z.f:
Perhaps you could post some code to look at. I've tried this with an ItemTemplate like so:
<form id="Form1" method="post" runat="server"> <asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns="False"> <Columns> <asp:BoundColumn DataField="au_id" HeaderText="au_id"/> <asp:TemplateColumn HeaderText="test"> <ItemTemplate> <asp:Button Runat="server" ID="button1" CausesValidation="False" /> </ItemTemplate> </asp:TemplateColumn> </Columns> </asp:DataGrid> <asp:TextBox Runat="server" ID="textbox1" /> <asp:RequiredFieldValidator Runat="server" ID="requiredFieldValidator" ControlToValidate="textbox1" ErrorMessage="You screwed up" /> <asp:Button Runat="server" ID="mainbutton" /> </form>
In this case pressing a button in the DataGrid does not cause validation.
-- Scott http://www.OdeToCode.com
On Thu, 24 Jun 2004 11:20:03 +0200, "z. f." <zi**@info-scopeREMSPAM.co.il> wrote:
Hi,
i stated that this is an advanced question because i have a post from few days ago that i received answers to with suggestions that looked good but did not work, so please if you post a reply make sure your suggestion actually works.
like a <asp:button> control have a CausesValidation property that allows
itto POST a button command event to the server without causing the page to make validation on form inputs, i need to get the same functionallity to
an<asp:button> culomn with a delete command.
i tried to use the OnItemCreated event of the datagrid, to add this property, but perhaps becuase the button inside the grid is actually an array of buttons, setting the property had no effect.
also tried to make an <TemplateItem> with the button inside, but again setting the property had no effect and the form did passed the validation check.
please advise, but don't just throw "why don't you try this", and as it
didlast time, it did not work.
i'm gessing there must be a way (even use javascript or something) - to
makea command from the grid row without passing the form validation.
TIA, z.
In this case it would be a little different than the grid delete
command. You can get to the DataGridItem by asking for the sender's
parent, like this:
protected void Button1_Click(object sender, System.EventArgs e)
{
Button btn = sender as Button;
// now btn.Parent is equivalent to
// e.Item in DataGrid_Delete command
}
You might also find this article that I wrote helpful:
Tips for locating controls with the FindControl method, including
finding controls in DataGrid rows, Repeaters, DataGrid headers, and
user controls: http://odetocode.com/Articles/116.aspx
--
Scott
On Thu, 24 Jun 2004 17:22:28 +0200, "z. f."
<zi**@info-scopeREMSPAM.co.il> wrote: i'll check it up ,
for now i managed to do with overriding the Validate method of the page object and only if i want to, i call MyBase.Validate()
but i will try your code as soon as i'll make another grid with delete buttons etc', that should not make validation of other operation that the page can do. question: the button inside the <asp:TemplateColumn HeaderText="test">, how it "knows" which id it acts for, do i need to write code in the OnItemCreated , or it can handle a grid command like delete?
--
Scott http://www.OdeToCode.com
The correct answer to the original question:
In OnItemCreated, retrieve the ButtonColumn object by its index in
e.Item.Cells. Then access the first control in its control collection. That
is the Button control. Finally set CausesValidation to false on that
control.
Suppose the buttonColumn was the second column. It uses an index of 1.
Here's code in C#:
Button vButton = (Button) e.Item.Cells[1].Controls[0];
vButton.CausesValidation = false;
--- Peter Blum www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at http://www.peterblum.com/vam/home.aspx
"z. f." <zi**@info-scopeREMSPAM.co.il> wrote in message
news:uy******************@TK2MSFTNGP12.phx.gbl... i'll check it up ,
for now i managed to do with overriding the Validate method of the page object and only if i want to, i call MyBase.Validate()
but i will try your code as soon as i'll make another grid with delete buttons etc', that should not make validation of other operation that the page can do. question: the button inside the <asp:TemplateColumn HeaderText="test">,
how it "knows" which id it acts for, do i need to write code in the OnItemCreated , or it can handle a grid command like delete? thanx.
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message news:gj********************************@4ax.com... Hi z.f:
Perhaps you could post some code to look at. I've tried this with an ItemTemplate like so:
<form id="Form1" method="post" runat="server"> <asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns="False"> <Columns> <asp:BoundColumn DataField="au_id" HeaderText="au_id"/> <asp:TemplateColumn HeaderText="test"> <ItemTemplate> <asp:Button Runat="server" ID="button1" CausesValidation="False" /> </ItemTemplate> </asp:TemplateColumn> </Columns> </asp:DataGrid> <asp:TextBox Runat="server" ID="textbox1" /> <asp:RequiredFieldValidator Runat="server" ID="requiredFieldValidator" ControlToValidate="textbox1" ErrorMessage="You screwed up" /> <asp:Button Runat="server" ID="mainbutton" /> </form>
In this case pressing a button in the DataGrid does not cause validation.
-- Scott http://www.OdeToCode.com
On Thu, 24 Jun 2004 11:20:03 +0200, "z. f." <zi**@info-scopeREMSPAM.co.il> wrote:
Hi,
i stated that this is an advanced question because i have a post from
fewdays ago that i received answers to with suggestions that looked good
butdid not work, so please if you post a reply make sure your suggestion actually works.
like a <asp:button> control have a CausesValidation property that
allows itto POST a button command event to the server without causing the page
tomake validation on form inputs, i need to get the same functionallity
to an<asp:button> culomn with a delete command.
i tried to use the OnItemCreated event of the datagrid, to add this property, but perhaps becuase the button inside the grid is actually an array of buttons, setting the property had no effect.
also tried to make an <TemplateItem> with the button inside, but again setting the property had no effect and the form did passed the
validationcheck.
please advise, but don't just throw "why don't you try this", and as it
didlast time, it did not work.
i'm gessing there must be a way (even use javascript or something) - to makea command from the grid row without passing the form validation.
TIA, z.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: GrantS |
last post by:
I am trying to convert the VB.Net code example povided by
http://authors.aspalliance.com/JimRoss/Articles/MaintainScrollPos.aspx
into C# (ASP.Net)without success. No errors are thrown in the VB...
|
by: James Norton-Jones |
last post by:
Hi,
Am I trying to hold the data of a DataGrid in a label so that when the form
is reposted the DataGrid can be repopulated. The problem I am having is that
I don't understand how to get the...
|
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...
|
by: z. f. |
last post by:
Hi,
i have a datagrid with a delete button for each row in the grid.
when the delete button is clicked i need to ask the user in a "confirm"
message box if he's sure he wants to delete.
the...
|
by: Alex Maghen |
last post by:
I have a DataGrid control with a LinkButton command column that deletes the
row. What I want to do is set it up so that there's a client-side Confirm
alert BEFORE the actual Delete command gets...
|
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=()=>{
|
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...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
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...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
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...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
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...
|
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...
| |