ASP.NET - Default Button on form with dropdowns and button only
<p>I have an ASP.NET page with some dropdown lists within a listview. At the bottom of the form is a submit button. </p>

<p>Whenever the user hits the "Enter" key I want the submit button pressed. I've done this on other forms with the DefaultButton attribute of a panel, but those had a textbox and a button in the panel.</p>

<p>The defaultbutton property is not triggering the submit button here, I think because the focus is not in the panel.</p>

<p>However if I make the panel include all of the elements this doesn't seem to work either. I think this is because of the html table layout elements.</p>

<p>So what is the answer to simple press the submit button when the user presses "Enter" on the keyboard?</p>

<pre><code>&lt;table cellpadding="3" cellspacing="1" border="0" width="100%"&gt;
    &lt;tr&gt;
        &lt;td align="center" width="100%" class="tableCaptionLabel" colspan="2"&gt;
        Asset Search by Photo
        &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr valign="top"&gt;
        &lt;td colspan="2"&gt;



        &lt;asp:ListView ID="lvQuery" runat="server" &gt;
            &lt;LayoutTemplate&gt;
            &lt;asp:Placeholder
            id="groupPlaceholder"
            runat="server" /&gt;
            &lt;/LayoutTemplate&gt;
            &lt;GroupTemplate&gt;
            &lt;div&gt;
            &lt;asp:Placeholder
            id="itemPlaceholder"
            runat="server" /&gt;
            &lt;/div&gt;
            &lt;/GroupTemplate&gt;
            &lt;ItemTemplate&gt;
            &lt;asp:DropDownList ID="tagname" runat="server" DataSourceID="sqldsTagList" SelectedValue='&lt;%# Bind("Tagname") %&gt;'
                    DataTextField="TagDesc" DataValueField="TagDesc"  AppendDataBoundItems ="true" AutoPostBack="true" OnSelectedIndexChanged="lstTagname_SelectedIndexChanged"&gt;
                    &lt;asp:ListItem Text="All" Value="All" /&gt;
            &lt;/asp:DropDownList&gt;

               &lt;asp:DropDownList ID="Operation" runat="server" SelectedValue='&lt;%# Bind("Operation") %&gt;' AutoPostBack="true" OnSelectedIndexChanged="lstOperation_SelectedIndexChanged"&gt;
                    &lt;asp:ListItem Text="Equals" Value="Equals" Selected="True"/&gt;
                    &lt;asp:ListItem Text="Like" Value="Like"  /&gt;
               &lt;/asp:DropDownList&gt;

            &lt;asp:TextBox ID="TagValue" runat="server" Text='&lt;%# Bind("TagValue") %&gt;' Width="75%"&gt;&lt;/asp:TextBox&gt;

            &lt;asp:DropDownList ID="ddlAlphabet" runat="server" Visible="false" AutoPostBack="true" OnSelectedIndexChanged="lstAlphabet_SelectedIndexChanged"&gt;
                &lt;asp:ListItem Text="A" Value="A" Selected="True"/&gt;
                &lt;asp:ListItem Text="B" Value="B"  /&gt;
                &lt;asp:ListItem Text="C" Value="C"  /&gt;
                &lt;asp:ListItem Text="D" Value="D"  /&gt;
                &lt;asp:ListItem Text="E" Value="E"  /&gt;
                &lt;asp:ListItem Text="F" Value="F"  /&gt;
                &lt;asp:ListItem Text="G" Value="G"  /&gt;
                &lt;asp:ListItem Text="H" Value="H"  /&gt;
                &lt;asp:ListItem Text="I" Value="I"  /&gt;
                &lt;asp:ListItem Text="J" Value="J"  /&gt;
                &lt;asp:ListItem Text="K" Value="K"  /&gt;
                &lt;asp:ListItem Text="L" Value="L"  /&gt;
                &lt;asp:ListItem Text="M" Value="M"  /&gt;
                &lt;asp:ListItem Text="N" Value="N"  /&gt;
                &lt;asp:ListItem Text="O" Value="O"  /&gt;
                &lt;asp:ListItem Text="P" Value="P"  /&gt;
                &lt;asp:ListItem Text="Q" Value="Q"  /&gt;
                &lt;asp:ListItem Text="R" Value="R"  /&gt;
                &lt;asp:ListItem Text="S" Value="S"  /&gt;
                &lt;asp:ListItem Text="T" Value="T"  /&gt;
                &lt;asp:ListItem Text="U" Value="U"  /&gt;
                &lt;asp:ListItem Text="V" Value="V"  /&gt;
                &lt;asp:ListItem Text="W" Value="W"  /&gt;
                &lt;asp:ListItem Text="X" Value="X"  /&gt;
                &lt;asp:ListItem Text="Y" Value="Y"  /&gt;
                &lt;asp:ListItem Text="Z" Value="Z"  /&gt;
                &lt;asp:ListItem Text="0" Value="0"  /&gt;
                &lt;asp:ListItem Text="1" Value="1"  /&gt;
                &lt;asp:ListItem Text="2" Value="2"  /&gt;
                &lt;asp:ListItem Text="3" Value="3"  /&gt;
                &lt;asp:ListItem Text="4" Value="4"  /&gt;
                &lt;asp:ListItem Text="5" Value="5"  /&gt;
                &lt;asp:ListItem Text="6" Value="6"  /&gt;
                &lt;asp:ListItem Text="7" Value="7"  /&gt;
                &lt;asp:ListItem Text="8" Value="8"  /&gt;
                &lt;asp:ListItem Text="9" Value="9"  /&gt;
            &lt;/asp:DropDownList&gt;
            &lt;/ItemTemplate&gt;
            &lt;EmptyItemTemplate&gt;           

            &lt;/EmptyItemTemplate&gt;
        &lt;/asp:ListView&gt;


        &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;
        &lt;asp:Panel runat="server" ID="pnlEnter" DefaultButton="btnQuery" &gt;
        &lt;asp:Button ID="btnQuery" runat="server" Text="Submit" /&gt;
        &lt;/asp:Panel&gt;
        &lt;/td&gt;
        &lt;td align="right"&gt;
        &lt;asp:Button ID="btnAddRow" runat="server" Text="Add Row" /&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;
</code></pre>
