asp.net

aspx页面引用命名空间

2011-02-19

我是想在aspx页面中将dataset中的某个值(新闻),直接写到html上,但如果在cs中取得了dataset,在aspx中好像不能直接调用,说是没定义,所以我想直接在aspx中直接写代码,把dataset值取出来用。

    这时就要将一些命名空间引用,在aspx页面中引用命名空间,不像cs中用using,而是用,<%@   Import   Namespace="" %>

    还有,如果是在aspx页面中获取 前一页传的参数:

    int id =Int32.Parse( this.Request.QueryString["id"]);

例:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="xx_ll_one.aspx.cs" Inherits="web_oa_xx_xx_ll_one" %>
<%@  Import   Namespace="System.Data"   %>
<%@  Import   Namespace="System.Data.SqlClient"   %>
<%@  Import   Namespace="jwglnet.DBUtility"   %>

<!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>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#5AAE18">
  <tr>
   <%   string whfs = "查询单条信息";
        int id=int.Parse(ViewState["id"].ToString());
      

        SqlParameter[] parameters = new SqlParameter[4];
        parameters[0] = new SqlParameter("@_whfs", whfs);
        parameters[1] = new SqlParameter("@_xq", "");
        parameters[2] = new SqlParameter("@_yhdm", "");
        parameters[3] = new SqlParameter("@_id",id );

        DataSet dsxx = DbHelperSQL.RunProcedure("pr_oa_xxgl_xxcx", parameters, "xxmp");
   %>
    <td bgcolor="#FFFFFF">
<p align="center"></p>
        <br/>
                             
 
<span class="style39">最后更新:<%=dsxx.Tables["xxmp"].Rows[0]["rq"]%> </span>

 
      <hr width="95%" size="1" color="#5AAE18" height="1"/>    
        <strong>
        </strong> <p>
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <%=dsxx.Tables["xxmp"].Rows[0]["nr"]%>                                       &nbsp;&nbsp;  
          </p>
        <p>
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 申请人:<%=dsxx.Tables["xxmp"].Rows[0]["username"]%> <br/>
           
                                          <%=dsxx.Tables["xxmp"].Rows[0]["rq"]%>  
        </p>
   
      <table width="334" border="0" cellspacing="0" cellpadding="0">
      
 
</table>
</table>
    </div>
    </form>
</body>
</html>