最近在研究一个东西,用asp .net显示查询数据库后的结果。
用table ,通过列把数据库查出的结果某几个字段显示出来,而且对应某一行还能获得它对应的ID号用来做删除操作。.NETASP数据库

解决方案 »

  1.   

    ajax配合ashx 类似        type: "get",
            url: encodeURI("../ashx/列表.ashx"),
            data: { "action": "查看指令列表", "page": page, "flag": flag, "px": px, "cid": num },
            cache: false,
            dataType: "json",
            beforeSend: function () {
                $("#e,#f").show();
            },
            complete: function () {
                $("#e,#f").hide();
            },
            success: function (data) {
                if (data.msg == "0") {
                    alert(data.msgbox);
                }
                else if (data.msg == "2") {
                    $("#pd").empty();
                    $(".fenye").empty();
                    $(".fenye").html(data.msgbox);
                }
                else {
                    $("#pd").empty();
                    $(data.msgbox).each(function () {
                        $('#pd').append("<tr>"
            + "<td align='center'>" + this.名称 + "</td>"
            + "<td align='center'>" + this.数量 + "</td>"
            + "<td align='center'>" + renderTime(this.时间) + "</td>"
            + "<td align='center'>" + (this.状态 == 2 ? "<img title='正常' src='../images/icon_correct.png' />" : "<img title='禁用' src='../images/icon_disable.png' />") + "</td>"
            + "<td align='center'>" + this.批次 + "</td>"
            + "<td align='center'>" + (this.状态 == 2 ? "<a disabled='disabled'>修改</a>" : "<a href='javascript:void(0)' onfocus='this.blur()' onclick='change($(this)," + this.数量 + "," + this.ID + ")'>修改</a>") + "</td>"
            + "<td align='center'>" + (this.状态 == 2 ? "<a disabled='disabled'>删除</a>" : "<a href='javascript:void(0)' onfocus='this.blur()' onclick='del($(this)," + this.ID + ")'>删除</a>") + "</td>"
            + "<td align='center'><a href='javascript:void(0)' onfocus='this.blur()' onclick='state($(this)," + this.ID + ")'>修改生产状态</a></td>"
            + "</tr>");
                    });
                    $(".fenye").empty();
                    $(".fenye").html(data.msg);
                    $("tr:nth-child(odd)").addClass("tr_odd_bg"); //隔行变色
                    $("tr").hover(
        function () {
            $(this).addClass("tr_hover_col");
        },
        function () {
            $(this).removeClass("tr_hover_col");
        }
        );
                }
            },
            error: function (error) {
                alert("error");
            }
        });
      

  2.   

    类似
    <%if (li != null){%><%foreach (fdhost.Model.中间库存 l in li){%>
    <tr>
    <td align="center"><%=l.ID%></td>
    <td align="center"><%=l.名称%></td>
    <td align="center"><%=l.数量%></td>
    </tr><%}%><%}%>
      

  3.   

    类似
    function renderTime(date) {
        var da = new Date(parseInt(date.replace("/Date(", "").replace(")/", "").split("+")[0]));
        return da.getFullYear() + "-" + (da.getMonth() + 1) + "-" + da.getDate();
    }function change(obj, num, id) {
        obj.parent().prev().prev().prev().prev().html("").append("<input type='text' name='ip' value='" + num + "' class='txtInput2 small2' onkeydown='return checkNumber(event);' />");
        obj.parent().html("").append("<a href='javascript:void(0)' onfocus='this.blur()' onclick='edit($(this)," + id + ")'>确定</a>");
    }function edit(obj, id) {
        var num = obj.parent().prev().prev().prev().prev().children().eq(0).val();
        $.ajax({
            type: "get",
            url: encodeURI("../ashx/审核.ashx"),
            data: { "action": "生产指令内容修改", "num": num, "id": id },
            cache: false,
            dataType: "json",
            success: function (data) {
                if (data.msg == "1") {
                    obj.parent().prev().prev().prev().prev().html("").append(num);
                    obj.parent().html("").append("<a href='javascript:void(0)' onfocus='this.blur()' onclick='change($(this)," + num + "," + id + ")'>修改</a>");
                }
                else {
                    alert(data.msgbox);
                }
            },
            error: function (error) {
                alert("error");
            }
        });
    }function del(obj, id) {
        $.ajax({
            type: "get",
            url: encodeURI("../ashx/审核.ashx"),
            data: { "action": "生产指令内容删除", "id": id },
            cache: false,
            dataType: "json",
            success: function (data) {
                if (data.msg == "1") {
                    obj.parent().parent().remove();
                }
                else {
                    alert(data.msgbox);
                }
            },
            error: function (error) {
                alert("error");
            }
        });
    }
      

  4.   

    这些那些是在aspx上的?哪些是在aspx.cs上的?
    请问怎么从aspx调用aspx.cs上的函数返回值,就像jsp那样在页面嵌入代码,.net 可以这样做吗?
      

  5.   

    在cs文件里
    public string test="test";前台页面
    <% =test%>也可以在前台做判断
    <%if(){ %>
    <input type="text" />
    <% }%>
    楼主说的问题可以用服务器控件例如Repeater控件实现