我这个查询按钮onclick事件不会写.传值不能搞定.高手帮我看看这个应该怎么写呀?
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title><script language="javascript" type="text/javascript">
// <!CDATA[function Button1_onclick() { 
          
}
// ]]>
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
       物品ID<input id="Text1" type="text" onclick="return Text1_onclick()" />
        <input id="Button1" type="button" value="确定" onclick="return Button1_onclick()" />
        <asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px">
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:jsgwebConnectionString %>"
                SelectCommand="SELECT [wpid], [wpxm], [wpmx], [wzdh], [klsj], [wzdz], [ghsj] FROM [klwp]" OnSelecting="SqlDataSource1_Selecting">
            </asp:SqlDataSource>
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="wpid"
                DataSourceID="SqlDataSource1" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
                <Columns>
                    <asp:BoundField DataField="wpid" HeaderText="wpid" ReadOnly="True" SortExpression="wpid" />
                    <asp:BoundField DataField="wpxm" HeaderText="wpxm" SortExpression="wpxm" />
                    <asp:BoundField DataField="wpmx" HeaderText="wpmx" SortExpression="wpmx" />
                    <asp:BoundField DataField="wzdh" HeaderText="wzdh" SortExpression="wzdh" />
                    <asp:BoundField DataField="klsj" HeaderText="klsj" SortExpression="klsj" />
                    <asp:BoundField DataField="wzdz" HeaderText="wzdz" SortExpression="wzdz" />
                    <asp:BoundField DataField="ghsj" HeaderText="ghsj" SortExpression="ghsj" />
                </Columns>
            </asp:GridView>
        </asp:Panel>
    </div>
    </form>
</body>
</html>

解决方案 »

  1.   

    首先你要在后台代码里定义一个全局的id,每次点查询的时候把值付给这个id
    然后在后台得到这个id来查询。
    function Button1_onclick() { 
          declare sql="select * from table where id ="+<%=id%>;
          <%SqlCommand comm=new SqlCommand(sql,conn);
           SqlDataReader reader=Comm.com.ExecuteReader();
           下面要干什么我就不知道了
           %>    
    }