如何使用Jquery将Html Select值传递给SqlDatasource?

时间:2015-03-18 17:40:23

标签: jquery asp.net repeater

     <strong>
      <asp:Repeater ID="rptordercount" runat="server" DataSourceID="OrdersCount">
             <ItemTemplate>
                <%# Eval("TotalCount")%>
                  </ItemTemplate>
                       </asp:Repeater>
                          order</strong> placed in</p>
                        <select id="idGetOrderPlaced" onchange="funcGetOrderPlaced()">
         <option value="1">past 1 months</option>
           <option value="3">past 3 months</option>
         <option selected="selected" value="6">past 6 months</option>
          <option value="12">past 12 months</option>
        </select>

这是我的sql数据源

  <asp:SqlDataSource ID="OrdersCount" runat="server" SelectCommand="exec spGetCountOrders @SessionID,@MonthCount"
    ConnectionString="<%$ ConnectionStrings:dbWRConnectionString %>" ProviderName="<%$ ConnectionStrings:dbWRConnectionString.ProviderName %>">
    <SelectParameters>
        <asp:SessionParameter Name="SessionID" Type="String" SessionField="SID" />
        <asp:ControlParameter Name="MonthCount" Type="String" ControlID="monthhidden" />
        <%--<asp:QueryStringParameter Name="MonthCount" Type="String" QueryStringField="MC" />--%>
    </SelectParameters>
</asp:SqlDataSource>

这样的Jquery方法
   function funcGetOrderPlaced() {
        //  rptordercountdiv
        debugger;
        var DataID = $("#idGetOrderPlaced").val();
        $("[id*='monthhidden']").val(DataID);
        $("#rptordercountdiv").html(DataID);
        // $("#rptordercount").val();
       // var url1 = '/MyAccount/ShowOrders.aspx/Method';
        var dd = '{count:' + $("#idGetOrderPlaced").val() + '}';
        $('#rptordercountdiv').val(dd);
        var url = '/MyAccount/ShowOrders.aspx?MC=' + DataID;
        debugger;
        var dataNew = null;
        $.get(url, function (data) {
            debugger;
            $('#divAllOrderHistory').html("");
            $('#divAllOrderHistory').append(data);
            dataNew = data;
        }, "html");

现在这里DataID获取Html选择控制值...此值传递给 我写proc像exec“spgetcountorders”来传递这个传递值.. 我怎么能通过这个?请帮帮我..

1 个答案:

答案 0 :(得分:1)

您是否可以访问SQLDataSource的Pre-Render中的隐藏值?

<asp:HiddenField ID="HiddenID" ClientIDMode="Static"
OnDataBinding="HiddenField_DataBinding"
OnPreRender="HiddenField_PreRender" value='<%# Bind("someValue") %>'
runat="server" />

protected void HiddenField_PreRender(object sender, EventArgs e)
{
//HiddenID.Value
}