0
<script type="text/javascript">
    $(document).on("click","tr.rows td", function(e){
        alert(e.target.innerHTML);
    });
    $(document).ready(function() {
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "HomePage.aspx/BindVehicleDetails",
            data: "{}",
            dataType: "json",
            success: function(data) {
                //alert(data.d);
                for (var i = 0; i < data.d.length; i++) {
                    // alert(data.d[i]);
                    var s= data.d[i];
                    $("#tbDetails").append("<tr><td onclick='senddata("+ data.d[i]     +")'>" + data.d[i]  + "</td></tr>");
                }
            },
            error: function(result) {
                alert("Error");
            }
        });
    });
</script>
<script type="text/javascript">
    function senddata(data)
    {
        alert(data);
        //window.location = "DashBoard.aspx?vehicleNo="+data";
        document.getElementById('contentChange').src="DashBoard.aspx?vehicleNo="+data;
    }
</script>




 <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
<form runat="server">

    <div id="mainContent">
        <div id="LeftNav">
            <div style="height: 300px; overflow: auto;">

                <table id="tbDetails" cellpadding="0" cellspacing="0">
                    <thead style="background-color: #DC5807; color: White; font-weight: bold">
                        <tr style="border: solid 1px #000000">
                            <td>Vehicle No </td>
                        </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </div>

            <%-- <asp:ListBox ID="lstVehicle" CssClass="vehicleHeader" runat="server"></asp:ListBox>--%>
        </div>
        <div class="continer">
            <div id="DashboardHeader">
                Dash Board
            </div>
            <iframe src="Dashboard.aspx" style="height: 420px; width: 100%; overflow: auto;" id="contentChange" frameborder="0"></iframe>
        </div>
    </div>

</form>
</asp:Content>

我有一个表,如果我单击任何一个表行意味着它只传递了一个整数参数行。未传递字符串参数。我不知道错误在哪里。该函数名称是“senddata()”,我认为问题出现在“$("#tbDetails").append("" + data.d[i] + "");" 仅行

4

1 回答 1

0

试试这个 DashBoard.aspx

int vehicleno= Int32.Parse(Request.QueryString["vehicleNo"]);

或者

int vehicleno=  Convert.ToInt32(Request.QueryString["vehicleNo"]);

这会将字符串解析为 int

希望这可以帮助

于 2013-09-12T06:37:37.007 回答