RequiredfiledValidator and regularexpressionvalidator in DataGrid footer

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default RequiredfiledValidator and regularexpressionvalidator in DataGrid footer

    I have a Datagrid with Update,Delete and Edit buttons.
    And on the footer i'm adding a new ROW to the DataGrid
    I placed RequiredfiledValidator and regularexpressionvalidator in the Footer
    of a DataGrid
    so that i can validate the TextBoxes but when i click the Submit button in
    the Footer it doesn't fire but then i click the
    the Delete button on any ROW of the Datagrid it fires the
    RequiredfiledValidator in the footer..
    Any ideas ?


    Patrick.O.Ige Guest

  2. Similar Questions and Discussions

    1. Datagrid Footer!
      Hi all, I am using a datagrid footer as a container for some data entry controls. Above the datagrid is another data entry point which needs to...
    2. ValidationSummary not displaying error message from datagrid regularExpressionValidator
      I have a datagrid with Edit, Update, Cancel. Everything without validation works fine but when the user edits the date column I would like the...
    3. datagrid footer question
      im keeping running totals of certain columns in a datagrid, id like to put these totals in the footer - how do i do this ? or how can i put a label...
    4. Datagrid Footer Image
      Hi - is it possible to add an image to the Footer in a datagrid? I have tried but just get a message saying it does not have a property asp:image...
    5. datagrid footer
      I'd like to know how to add a text box in the datagrid footer at runtime. Thanks.
  3. #2

    Default Re: RequiredfiledValidator and regularexpressionvalidator in DataGrid footer

    Check the button's CausesValidation property. If it's set to false, it
    doesn't fire validation.

    HTH


    "Patrick.O.Ige" <naijacoder@hotmail.com> wrote in message
    news:ODL1Nwj6FHA.2020@TK2MSFTNGP10.phx.gbl...
    >I have a Datagrid with Update,Delete and Edit buttons.
    > And on the footer i'm adding a new ROW to the DataGrid
    > I placed RequiredfiledValidator and regularexpressionvalidator in the
    > Footer
    > of a DataGrid
    > so that i can validate the TextBoxes but when i click the Submit button in
    > the Footer it doesn't fire but then i click the
    > the Delete button on any ROW of the Datagrid it fires the
    > RequiredfiledValidator in the footer..
    > Any ideas ?
    >
    >

    Elton Wang Guest

  4. #3

    Default Re: RequiredfiledValidator and regularexpressionvalidator in DataGrid footer

    Thanks Elton for the reply..but my detailed question is below:-

    I have a Datagrid with Update/Edit/Cancel in the EditCommandColumn
    And an insert Button in the footer to add new record..
    I have set RequiredFieldValidator in the FOOTER to validate text
    fields before inserting data..
    Now i added another ones in the EditTemplate to check values before
    updating...
    When i Click on the Update button in the EditCommandColumn
    it triggers the requiredfiledvalidator for the insert button and text
    fileds.
    How can i access the update button in the EditCommandColumn in the
    edit mode?
    Or how can i set the insert button in the footer to
    CausesValidation=False when the update button is in the edit mode..??



    "Elton Wang" <elton_wang@hotmail.com> wrote in message
    news:ez8Rk7t6FHA.3340@TK2MSFTNGP10.phx.gbl...
    > Check the button's CausesValidation property. If it's set to false, it
    > doesn't fire validation.
    >
    > HTH
    >
    >
    > "Patrick.O.Ige" <naijacoder@hotmail.com> wrote in message
    > news:ODL1Nwj6FHA.2020@TK2MSFTNGP10.phx.gbl...
    > >I have a Datagrid with Update,Delete and Edit buttons.
    > > And on the footer i'm adding a new ROW to the DataGrid
    > > I placed RequiredfiledValidator and regularexpressionvalidator in the
    > > Footer
    > > of a DataGrid
    > > so that i can validate the TextBoxes but when i click the Submit button
    in
    > > the Footer it doesn't fire but then i click the
    > > the Delete button on any ROW of the Datagrid it fires the
    > > RequiredfiledValidator in the footer..
    > > Any ideas ?
    > >
    > >
    >
    >

    Patrick.O.Ige Guest

  5. #4

    Default Re: RequiredfiledValidator and regularexpressionvalidator in DataGrid footer

    Hi Patrick,

    It's a little trick. Before a row becomes Edit state, the update button is
    no available. So one way to do it is that in DataGrid_EditCommand event:

    DataGrid.EditItemIndex = e.Item.ItemIndex;
    DataGrid.DataSource = dataObj;
    DataGrid.DataBind();
    // up to now the e.Item.ItemIndex 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)this.DataGrid.Items[e.Item.ItemIndex].Cells[button_col_index].Controls[0];
    // then set its CausesValidation
    updateBtn.CausesValidation = true/false;

    If you have ID for the insert button in footer, you meight use

    DataGrid.FindControl("insert_button_ID") to refer the button.

    HTH


    "Patrick.O.Ige" <naijacoder@hotmail.com> wrote in message
    news:e16ZQxv6FHA.1944@TK2MSFTNGP14.phx.gbl...
    > Thanks Elton for the reply..but my detailed question is below:-
    >
    > I have a Datagrid with Update/Edit/Cancel in the EditCommandColumn
    > And an insert Button in the footer to add new record..
    > I have set RequiredFieldValidator in the FOOTER to validate text
    > fields before inserting data..
    > Now i added another ones in the EditTemplate to check values before
    > updating...
    > When i Click on the Update button in the EditCommandColumn
    > it triggers the requiredfiledvalidator for the insert button and text
    > fileds.
    > How can i access the update button in the EditCommandColumn in the
    > edit mode?
    > Or how can i set the insert button in the footer to
    > CausesValidation=False when the update button is in the edit mode..??
    >
    >
    >
    > "Elton Wang" <elton_wang@hotmail.com> wrote in message
    > news:ez8Rk7t6FHA.3340@TK2MSFTNGP10.phx.gbl...
    >> Check the button's CausesValidation property. If it's set to false, it
    >> doesn't fire validation.
    >>
    >> HTH
    >>
    >>
    >> "Patrick.O.Ige" <naijacoder@hotmail.com> wrote in message
    >> news:ODL1Nwj6FHA.2020@TK2MSFTNGP10.phx.gbl...
    >> >I have a Datagrid with Update,Delete and Edit buttons.
    >> > And on the footer i'm adding a new ROW to the DataGrid
    >> > I placed RequiredfiledValidator and regularexpressionvalidator in the
    >> > Footer
    >> > of a DataGrid
    >> > so that i can validate the TextBoxes but when i click the Submit button
    > in
    >> > the Footer it doesn't fire but then i click the
    >> > the Delete button on any ROW of the Datagrid it fires the
    >> > RequiredfiledValidator in the footer..
    >> > Any ideas ?
    >> >
    >> >
    >>
    >>
    >
    >

    Elton Wang Guest

  6. #5

    Default Re: RequiredfiledValidator and regularexpressionvalidator in DataGrid footer

    Thx Elto i figured it out.
    I actually noticed that problem when i had to make use of Validators in both
    the insert and Edit /update mode.
    What actually i did earlier was to set the SHOWFOOTER visible=false when in
    edit mode and that worked.
    But if i set my update button to CausesValidation=false as you requested my
    validators won't fire.
    Unless i set the insert button in the FOOTER to CausesValidation=false when
    in Edit mode.
    Patrick



    "Elton Wang" <elton_wang@hotmail.com> wrote in message
    news:er#pn686FHA.3804@TK2MSFTNGP14.phx.gbl...
    > Hi Patrick,
    >
    > It's a little trick. Before a row becomes Edit state, the update button is
    > no available. So one way to do it is that in DataGrid_EditCommand event:
    >
    > DataGrid.EditItemIndex = e.Item.ItemIndex;
    > DataGrid.DataSource = dataObj;
    > DataGrid.DataBind();
    > // up to now the e.Item.ItemIndex 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)this.DataGrid.Items[e.Item.ItemIndex].Cells[button_col_index].Co
    ntrols[0];
    > // then set its CausesValidation
    > updateBtn.CausesValidation = true/false;
    >
    > If you have ID for the insert button in footer, you meight use
    >
    > DataGrid.FindControl("insert_button_ID") to refer the button.
    >
    > HTH
    >
    >
    > "Patrick.O.Ige" <naijacoder@hotmail.com> wrote in message
    > news:e16ZQxv6FHA.1944@TK2MSFTNGP14.phx.gbl...
    > > Thanks Elton for the reply..but my detailed question is below:-
    > >
    > > I have a Datagrid with Update/Edit/Cancel in the EditCommandColumn
    > > And an insert Button in the footer to add new record..
    > > I have set RequiredFieldValidator in the FOOTER to validate text
    > > fields before inserting data..
    > > Now i added another ones in the EditTemplate to check values before
    > > updating...
    > > When i Click on the Update button in the EditCommandColumn
    > > it triggers the requiredfiledvalidator for the insert button and
    text
    > > fileds.
    > > How can i access the update button in the EditCommandColumn in the
    > > edit mode?
    > > Or how can i set the insert button in the footer to
    > > CausesValidation=False when the update button is in the edit mode..??
    > >
    > >
    > >
    > > "Elton Wang" <elton_wang@hotmail.com> wrote in message
    > > news:ez8Rk7t6FHA.3340@TK2MSFTNGP10.phx.gbl...
    > >> Check the button's CausesValidation property. If it's set to false, it
    > >> doesn't fire validation.
    > >>
    > >> HTH
    > >>
    > >>
    > >> "Patrick.O.Ige" <naijacoder@hotmail.com> wrote in message
    > >> news:ODL1Nwj6FHA.2020@TK2MSFTNGP10.phx.gbl...
    > >> >I have a Datagrid with Update,Delete and Edit buttons.
    > >> > And on the footer i'm adding a new ROW to the DataGrid
    > >> > I placed RequiredfiledValidator and regularexpressionvalidator in the
    > >> > Footer
    > >> > of a DataGrid
    > >> > so that i can validate the TextBoxes but when i click the Submit
    button
    > > in
    > >> > the Footer it doesn't fire but then i click the
    > >> > the Delete button on any ROW of the Datagrid it fires the
    > >> > RequiredfiledValidator in the footer..
    > >> > Any ideas ?
    > >> >
    > >> >
    > >>
    > >>
    > >
    > >
    >
    >

    Patrick.O.Ige Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139