We're aware that some users are experiencing technical issues which the team are working to resolve. See the Community Noticeboard for more info. Thank you for your patience.
📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!

Weird .NET gridview behaviour

Options
dave82_2
dave82_2 Posts: 1,328 Forumite
Hi,

If I create a databound grid view with a footer containing a textbox and a button. The button has the attribute
CommandName="Add" set When I press enter in the textbox a postback occurs however the GridViews RowCommand event does not fire. If I add a second text box the RowCommand event does fire!

Anyone able to help?

Cheers Dave

Comments

  • dave82_2
    dave82_2 Posts: 1,328 Forumite
    So basically if I do this

    <FooterTemplate> 
         <asp:TextBox ID="tbxQuantity" runat="server"></asp:TextBox>
    </FooterTemplate>
    

    it doesn't fire the GridView RowCommand even when I press enter in the textbox

    If I do this it does fire the GridView RowCommand event!!

    [/SIZE]
    <FooterTemplate> 
         <asp:TextBox ID="tbxQuantity" runat="server"></asp:TextBox>
         <asp:TextBox ID="stupidfix" runat="server" style="display:none"></asp:TextBox>
    </FooterTemplate>
    
  • RobTang
    RobTang Posts: 1,064 Forumite
    Its a 'Feature' in asp.net webforms.

    Beacuse asp.net webforms demands only 1 runat server form, it creates problems when you hit enter (ie does a form submit),and it normall tries work out what text box you pressed enter in.

    When you only have a single textbox on the page, it automaticaly assumes that textbox was source and seems to bypass the control checking and doesn't do the correct postback.
  • dave82_2
    dave82_2 Posts: 1,328 Forumite
    Cheers. Got to love these microsoft 'features' :j
This discussion has been closed.
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 350.8K Banking & Borrowing
  • 253.1K Reduce Debt & Boost Income
  • 453.5K Spending & Discounts
  • 243.8K Work, Benefits & Business
  • 598.7K Mortgages, Homes & Bills
  • 176.8K Life & Family
  • 257.1K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16.1K Discuss & Feedback
  • 37.6K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.