首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

用asp .net显示查询数据库后的结果

2013-08-23 
求助 用asp .net显示查询数据库后的结果最近在研究一个东西,用asp .net显示查询数据库后的结果。用table ,

求助 用asp .net显示查询数据库后的结果
最近在研究一个东西,用asp .net显示查询数据库后的结果。
用table ,通过列把数据库查出的结果某几个字段显示出来,而且对应某一行还能获得它对应的ID号用来做删除操作。 .NET ASP 数据库
[解决办法]
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");
        }
    });



[解决办法]
类似


<%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><%}%><%}%>

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

在cs文件里

public string test="test";

前台页面

<% =test%>

也可以在前台做判断
<%if(){ %>
<input type="text" />
<% }%>

楼主说的问题可以用服务器控件例如Repeater控件实现

热点排行