用户编号:<asp:TextBox ID="TextBox7" runat="server" Height="18px" Width="120px" 
                        MaxLength="8" ></asp:TextBox>
        &nbsp; &nbsp;
        <asp:Button ID="Button7" runat="server" Text="查 询" /></td>
                <td>
                    片区:<asp:DropDownList ID="DropDownList6" runat="server" >
                    <asp:ListItem Value="100000" >01</asp:ListItem>
                    <asp:ListItem Value="200000" >02</asp:ListItem>
                    <asp:ListItem Value="200000" >03</asp:ListItem>
                    </asp:DropDownList>
                    &nbsp;&nbsp;&nbsp;<asp:Button ID="Button6" runat="server" Text="查 询" /></td>
现在的情况是按哪个都能执行查询,而且
<asp:SqlDataSource ID="SqlDataSource6" runat="server"
<SelectParameters>
                            <asp:ControlParameter ControlID="DropDownList6" Name="i" PropertyName="SelectedValue" />
                        </SelectParameters>
                    </asp:SqlDataSource>
这个查询在页面载入时就执行查询了,我希望按Button6后执行查询。下面这个应该在按Button7后执行查询。
<asp:SqlDataSource ID="SqlDataSource7" runat="server" ConnectionString="<%$ ConnectionStrings:zlsConnectionString7 %>"
            <SelectParameters>
                <asp:ControlParameter ControlID="TextBox7" Name="UserID" PropertyName="Text" />
            </SelectParameters>

解决方案 »

  1.   

    一个都查询不了,没有哦事件触发,无法绑定数据。
    首先问题是你的数据绑定给谁没有定义。Button触发後已经不执行查询了。现在数据查询工作已经被Sqldatasourse做完了,关键是出力数据的绑定显示,这个工作由Button来做,所以哪个bUtton执行了DataBind()事件,就是哪个Button能够执行查询。
      

  2.   

    微软怎么没告诉我,asp.net没有后台VB.net其实什么都干不了的。总结归纳,不学代码还是不行的,什么可视化编程,骗人的。我做了9个页面到现在才发现全部要重写,晕死。其实ado.net用vb.net写可移植性通用性更好.