Datagrid add/insert row validation issue

G

Guest

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 (an
insert or an update to record)

Add link:
<FooterTemplate>
<asp:LinkButton id="btnAddRow" runat="server" CssClass="gridqtext"
Text="<u>Add</u>" CommandName="Update" CommandArgument="Insert">
</asp:LinkButton>
</FooterTemplate>

edit links:
<asp:EditCommandColumn ItemStyle-Width="75" ItemStyle-CssClass="gridtext"
ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel"
EditText="Edit">
</asp:EditCommandColumn>

they are both sharing the:
Private Sub gdconcerndetail_UpdateCommand(ByVal source As System.Object,
ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
gdconcerndetail.UpdateCommand

Ideas? Thanx.
 
G

Guest

just noticed post in Jan, but solution was there isn't one I guess?
Does anyone know some good customvalidator examples that maybe can be used
here?

thanx.
 
E

Elton Wang

Hi Chris,

If the problem is about validation, you might disable
client-side validation and use server-side validation.

If the problem is two buttons share UpDate_Command event,
you can change CommandName of button in footer, i.e. to
Add, then handle datagrid_ItemCommand Event:

If e.CommandName = "Add" Then
' process
End

Actually, ItemCommand Occurs when any button is clicked in
the DataGrid control.

HTH,

Elton Wang
(e-mail address removed)
 
G

Guest

I'm trying to understand your response, maybe I'm not understanding it.
This is a validation issue, meaning the form ca not be submitted, etc.
So even though I have e.CommandArgument = "Insert" (see the tag in the first
post below) it never reaches it becuase the validation fails.
The strange thing is when I add a record, the validation is only for that
row The footer). When I enter into edit on a row then try to update that row
the validation fires first for add only('insert')?
the edit column doesn't have any arguments
edit links:
 
E

Elton Wang

Hi

I didn't fully understand your question. Now I got it.

Client-side validation logic doesn't care, actually
doesn't know which button is clicked. To client-side it
either submit or not depending validated fields. So it's
difficult to control its workflow. In that case, you might
change it to server-side validation. On server-side, if
button in footer is clicked, you know you don't need worry
about textbox in edit field, so you only check text fields
in footer, vice versa. The disadvantage of server-side
validation is negative performance and there is no any pre-
built control. You have you're your own validation logic.


HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top