各位,帮忙看看是什么错误啊????
cs中的代码:
protected void Page_Load(object sender, EventArgs e) 
    { 
        if (!this.IsPostBack) 
        { 
            string newsid = Request.QueryString["newsID"].ToString();             SqlConnection con = DB.createCon(); 
            SqlCommand cmd = new SqlCommand(); 
            cmd.Connection = con; 
            con.Open(); 
            cmd.CommandText = "select * from newsTable where newsID='"+newsid+"'"; 
            SqlDataReader sdr = cmd.ExecuteReader(); 
            while (sdr.Read()) 
            { 
                this.lbl_newsTitle.Text = sdr["newsTitle"].ToString(); 
                this.Label1.Text = sdr["editer"].ToString(); 
                this.Label2.Text = sdr["source"].ToString(); 
                this.Label3.Text = sdr["upDatetime"].ToString(); 
                this.lbl_content.Text = sdr["content"].ToString(); 
            } 
            sdr.Close(); 
        } 
    } GridView中:
                  <Columns> 
                    <asp:TemplateField> 
                        <ItemTemplate> 
                            &nbsp;* 
                        </ItemTemplate> 
                    </asp:TemplateField> 
                    <asp:HyperLinkField DataNavigateUrlFields="newsID" DataNavigateUrlFormatString="shownews.aspx?newsID={0}" 
                        DataTextField="newsTitle" NavigateUrl="~/shownews.aspx" Target="_blank" /> 
                </Columns> 错误提示:
无法找到资源。 
说明: HTTP 404。您正在查找的资源(或者它的一个依赖项)可能已被移除,或其名称已更改,或暂时不可用。请检查以下 URL 并确保其拼写正确。 

解决方案 »

  1.   

    跟踪调试了一下,newid的值为空!
    错误:
    未将对象引用设置到对象的实例。
    ?????
      

  2.   

    cmd.CommandText = "select * from newsTable where newsID='"+newsid+"'"; 
    数据库里newsid为字符串?不是的话不要用'';
      

  3.   

    显示新闻 最好用repeater控件
      

  4.   

    url 有没有传值啊?Request.QueryString["newsID"]是不是空的?
      

  5.   

    cmd.CommandText = "select * from newsTable where newsID='"+newsid+"'";-----------------newID是int型的吧?不是字符型的 ,修改为:
    cmd.CommandText = "select * from newsTable where newsID="+newsid;
      

  6.   

    shownews.aspx?newsID={0}" 
    还有这个你确定是和你现在的页面在同一目录下吗,看一下是不是路径写错了
      

  7.   

    你自己看看你写的这段程序,漏洞百出:protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                string newsid = Request.QueryString["newsID"].ToString(); //十分大胆的写法:你确定一定会有newID传入么?如果你把地址栏传入的?newID=..去掉,会发生什么?string newsid =string.isNullOrEmpty(Request.QueryString["newsID"])?"0":Request.QueryString["newID"];            SqlConnection con = DB.createCon();
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = con;
                con.Open();
                cmd.CommandText = "select * from newsTable where newsID='"+newsid+"'"; //很明显的错误,如果newID是int类型
                SqlDataReader sdr = cmd.ExecuteReader();
                //建议在这里加个if(sdr!=null){
                while (sdr.Read())
                {
                    this.lbl_newsTitle.Text = sdr["newsTitle"].ToString();
                    this.Label1.Text = sdr["editer"].ToString();
                    this.Label2.Text = sdr["source"].ToString();
                    this.Label3.Text = sdr["upDatetime"].ToString();
                    this.lbl_content.Text = sdr["content"].ToString();
                }
                //}
                sdr.Close();
            }
        } 
      

  8.   

    在aspx页面直接绑定嘛,我也做过类似的东西,我是在aspx页面绑定的。
      

  9.   

    NavigateUrl="~/shownews.aspx"
    应该是找不到这个页面吧?
      

  10.   

    支持楼上的
    应该是
    NavigateUrl="~/shownews.aspx" 这里出了错吧
      

  11.   

     <asp:HyperLinkField DataNavigateUrlFields="newsID" DataNavigateUrlFormatString="~/shownews.aspx?newsID={0}" 
                            DataTextField="newsTitle" NavigateUrl="~/shownews.aspx" Target="_blank" /> 
      

  12.   

    删除NavigateUrl="~/shownews.aspx"
     string newsid = Request.QueryString["newsID"]==null?"".Request.QueryString["newsID"].ToString();