在编写代码里实现当id=xml里的id时 在另个网页的tabel里显示商品详细信息
DataShow(String id)方法可以不用看 是在网页中显示的信息  是正确的因为当我把 string id = Request.QueryString["TypeId"].ToString();
改成id=311时 就显示了一个出来
但是我想实现两个都显示 用到了上面的段代码却显示不出来 
请问有什么错的地方?public partial class cp : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) {
            string id = Request.QueryString["TypeId"].ToString();
            DataShow(id);        }
    }
//方法参考
//方法参考
//方法参考
   private void DataShow(String id){
        DataSet ds=new DataSet();
        FileStream fs=new  FileStream(Server.MapPath("cp.xml"),FileMode.Open );
        ds.ReadXml(fs);
        for(int i=0;i<ds.Tables[0].Rows.Count;i++){
        if(ds.Tables[0].Rows[i]["TypeId"].ToString()==id)
        {
            Label1.Text=ds.Tables[0].Rows[i]["Name"].ToString();
            Label2.Text=ds.Tables[0].Rows[i]["TypeId"].ToString();
            Label7.Text=Label3.Text=ds.Tables[0].Rows[i]["PinPai"].ToString();
            Label4.Text=ds.Tables[0].Rows[i]["Color"].ToString();
            Label5.Text=ds.Tables[0].Rows[i]["OldPrice"].ToString();
            Label6.Text=ds.Tables[0].Rows[i]["NewPrice"].ToString();
          // IMG2.src=ds.Tables[0].Rows[i]["image"].ToString();
        Label8.Text="型号为:"+Label2.Text+" "+Label1.Text+" "+ds.Tables[0].Rows[i]["introduct"].ToString();
        }
        }
        fs.Close();    }
}
//xml参考
//xml参考
//xml参考
 <product>
    <Name>耐克运动鞋</Name>
    <TypeID>311</TypeID>
    <PinPai>耐克</PinPai>
    <Color>白</Color>
    <OldPrice>660</OldPrice>
    <NewPrice>330</NewPrice>
    <image>image/product_doine.gif</image>
    <introduct>hao</introduct>
  </product>  <product>
    <Name>阿迪达包</Name>
    <TypeID>312</TypeID>
    <PinPai>耐克</PinPai>
    <Color>白</Color>
    <OldPrice>660</OldPrice>
    <NewPrice>330</NewPrice>
    <image>image/product_doine.gif</image>
    <introduct>hao</introduct>
  </product>在显示页面有这样几段代码我也看不懂
 <td>
                                <a href='cp.aspx?TypeId=<%#DataBinder.Eval(Container.DataItem,"TypeID") %> '>
                                
                                <img  src='<%#DataBinder.Eval(Container.DataItem,"image") %>'/>
如果还有什么代码要贴的可以跟我说

解决方案 »

  1.   

    <a href='cp.aspx?TypeId=<%#DataBinder.Eval(Container.DataItem,"TypeID") %> '>
    意思是把TypeID自带的值进行绑定,生成一个链接
    结果可能是
    <a href='cp.aspx?TypeId=311'>
    <a href='cp.aspx?TypeId=312'>
    这样的
    <img src='<%#DataBinder.Eval(Container.DataItem,"image") %>'/>
    是显示图片,图片的src书数据源中的image字段
      

  2.   

    本帖最后由 net_lover 于 2011-12-11 14:16:37 编辑
      

  3.   

    谢谢提醒 但我还想问下 我把string id="311"时可以执行出来 但写成string id = Request.QueryString["TypeId"].ToString();
    时 两个都显示不出来 还提示未将对象引用设置到对象的实例。这是什么意思?
     怎么改?难道是我那条代码写错了?
      

  4.   

    谢谢提醒 但我还想问下 我把string id="311"时可以执行出来 但写成string id = Request.QueryString["TypeId"].ToString();
    时 两个都显示不出来 还提示未将对象引用设置到对象的实例。这是什么意思?
     怎么改?难道是我那条代码写错了?