Home/ASP.NET Forums/General ASP.NET/Web Forms Data Controls/GridView with insert from Footer if gridview is empty

GridView with insert from Footer if gridview is empty [Answered]RSS

20 replies

Last post Feb 10, 2010 05:38 AM by ziazai123

  • ziazai123

    ziazai123

    Member

    324 Points

    1187 Posts

    Re: GridView with insert from Footer if gridview is empty

    Feb 09, 2010 09:00 AM|ziazai123|LINK

    decker dong - msft

    Well, that's strange.

    I guess you can  try something like this:

    Protected Sub odsProgress_Inserting(ByVal sender As ObjectByVal e As System.Web.UI.WebControls.ObjectDataSourceMethodEventArgs) Handles odsProgress.Inserting   

  •   'Try to find RequiredValidator and use validate first, then do if(Page.IsValid())
  • ' Do what you have now
  •  

    Something I found. Before I put ValidationGroup= MyInsert in both texbox and RequiredFieldValidator thats why it was not validating. When I removed ValidationGroup from RequiredFieldValidator, it asked to insert text in textbox. So it is working but there is another question aroused.

    I have another FormView in the same page populated with some other datasource. This FormView is to update data but when I cliked Insert button without having text in the textbox of the requiredfiledvalidator and at the same time I clicked to update ForwView to update data then it is updating. In this situation I am able to just only Cancel the updation and put data in the textbox of the validator and click insert. After that I can update FormView.

    I want to make work seperately both gridview and formview.

    Hope you understand!

    Ziauddin
    Abu Dhabi (UAE)
  • shawpnendu

    shawpnendu

    Contributor

    3091 Points

    875 Posts

    Re: GridView with insert from Footer if gridview is empty

    Feb 09, 2010 11:53 AM|shawpnendu|LINK

    Strange.... OK Remove validationgroup from textbox & assign to button tag by appropriate validation group.

    Shawpnendu Bikash Maloroy
    MCTS
    www.codedisplay.com
  • ziazai123

    ziazai123

    Member

    324 Points

    1187 Posts

    Re: GridView with insert from Footer if gridview is empty

    Feb 09, 2010 02:53 PM|ziazai123|LINK

    shawpnendu

    assign to button tag by appropriate validation group.

     

    What do you mean by apporopriate group. By looking my above code, could you suggest appropriate?

    Ziauddin
    Abu Dhabi (UAE)
  • shawpnendu

    shawpnendu

    Contributor

    3091 Points

    875 Posts

    Re: GridView with insert from Footer if gridview is empty

    Feb 10, 2010 05:06 AM|shawpnendu|LINK

    I guess you have two validation group. Am i right? ALso you have two submit button. For which sublimt button you want to fire which validation group? Just assign that. For an example see the below code snippet:

    <asp:TextBox ID="txt1" runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator runat="server" ID="rq1" ErrorMessage="*" ValidationGroup="1" ControlToValidate="txt1"></asp:RequiredFieldValidator>
    <asp:Button runat="server" ID="cmd1" Text="cmd1" ValidationGroup="1" /></br>
    <asp:TextBox ID="txt2" runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator runat="server" ID="rq2" ErrorMessage="*" ControlToValidate="txt2" ValidationGroup="2"></asp:RequiredFieldValidator>
    <asp:Button runat="server" ID="cmd2" Text="cmd2" ValidationGroup="2" />

     Let me know if you can't understand.

    Shawpnendu Bikash Maloroy
    MCTS
    www.codedisplay.com
  • ziazai123

    ziazai123

    Member

    324 Points

    1187 Posts

    Re: GridView with insert from Footer if gridview is empty

    Feb 10, 2010 05:38 AM|ziazai123|LINK

    shawpnendu

    I guess you have two validation group. Am i right? ALso you have two submit button. For which sublimt button you want to fire which validation group? Just assign that. For an example see the below code snippet:

    <asp:TextBox ID="txt1" runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator runat="server" ID="rq1" ErrorMessage="*" ValidationGroup="1" ControlToValidate="txt1"></asp:RequiredFieldValidator>
    <asp:Button runat="server" ID="cmd1" Text="cmd1" ValidationGroup="1" /></br>
    <asp:TextBox ID="txt2" runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator runat="server" ID="rq2" ErrorMessage="*" ControlToValidate="txt2" ValidationGroup="2"></asp:RequiredFieldValidator>
    <asp:Button runat="server" ID="cmd2" Text="cmd2" ValidationGroup="2" />

     Let me know if you can't understand.

     

    Yes you are right. I have changed my code as per your suggestion.

    Thanks, now it is done.

    I am closing this Post because I found my answers.

    Thanks for support received from all contributors.

    Ziauddin
    Abu Dhabi (UAE)
  • ‹ Previous Thread|Next Thread ›