RequiredfiledValidator and regularexpressionvalidator in DataGrid footer

Discussion in 'ASP .Net Datagrid Control' started by Patrick.O.Ige, Nov 15, 2005.

  1. 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, Nov 15, 2005
    #1
    1. Advertising

  2. Patrick.O.Ige

    Elton Wang Guest

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

    HTH


    "Patrick.O.Ige" <> wrote in message
    news:...
    >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, Nov 16, 2005
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:...
    > Check the button's CausesValidation property. If it's set to false, it
    > doesn't fire validation.
    >
    > HTH
    >
    >
    > "Patrick.O.Ige" <> wrote in message
    > news:...
    > >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, Nov 16, 2005
    #3
  4. Patrick.O.Ige

    Elton Wang Guest

    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" <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:...
    >> Check the button's CausesValidation property. If it's set to false, it
    >> doesn't fire validation.
    >>
    >> HTH
    >>
    >>
    >> "Patrick.O.Ige" <> wrote in message
    >> news:...
    >> >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, Nov 17, 2005
    #4
  5. 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" <> wrote in message
    news:er#...
    > 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" <> wrote in message
    > news:...
    > > 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" <> wrote in message
    > > news:...
    > >> Check the button's CausesValidation property. If it's set to false, it
    > >> doesn't fire validation.
    > >>
    > >> HTH
    > >>
    > >>
    > >> "Patrick.O.Ige" <> wrote in message
    > >> news:...
    > >> >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, Nov 18, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. kgs
    Replies:
    2
    Views:
    497
  2. =?Utf-8?B?TWF0dCBNb3JyaXM=?=

    RegularExpressionValidator and Globalization

    =?Utf-8?B?TWF0dCBNb3JyaXM=?=, Feb 16, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    441
    =?Utf-8?B?TWF0dCBNb3JyaXM=?=
    Feb 16, 2005
  3. venkat Murthy
    Replies:
    0
    Views:
    738
    venkat Murthy
    Apr 21, 2005
  4. Markus
    Replies:
    0
    Views:
    649
    Markus
    Mar 2, 2005
  5. Henrik
    Replies:
    1
    Views:
    463
    Ken Cox [Microsoft MVP]
    Jul 6, 2006
Loading...

Share This Page