private void Bind()
    {
        String P_id = Request.QueryString["P_id"].ToString();
        SqlConnection con = Dcon.createConnection();
        SqlDataAdapter sda = new SqlDataAdapter();
        sda.SelectCommand = new SqlCommand("select *, '../../'+P_img as P_img1 from Product where P_id='" + P_id + "'", con);
        DataSet ds = new DataSet();
        sda.Fill(ds, "pro");
        this.Pr_dtl.DataSource = ds.Tables["pro"];
        this.Pr_dtl.DataBind();
    }还有一个text控件:
<asp:TextBox ID="pid" runat="server"></asp:TextBox>如何的把pid 这个值賦給  text??

解决方案 »

  1.   

    <asp:TextBox ID="pid" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"pid") %>'></asp:TextBox>
      

  2.   

    <asp:TextBox ID="pid" runat="server" Text=' <%# Eval("绑定字段") %>'> </asp:TextBox> 
      

  3.   

    for (int i = 0; i < dataset.Tables[pro].Rows.Count; i++)
                {
               
                       pid.text =dataset.Tables["pro"].Rows[i][0].ToString();
                  
                }
    不知道对lz的意思有没理解对
      

  4.   

    你这里好几个PID  哪个PID?
      

  5.   

    错误 2 “System.Web.UI.Control”并不包含“DataItem”的定义
      

  6.   

    - -#  真折磨人啊pid.text=P_id.ToString(); 你是要这个意思么????好象不是吧貌似太低等了!
      

  7.   

    他这个是写在你Pr_dtl模板列中的
     <asp:TextBox ID="pid" runat="server" Text=' <%# Eval("pid") >) %>'> </asp:TextBox> 
    <%# Eval("pid") 是你查询表中的列名字
      

  8.   

    http://blog.csdn.net/xianfajushi/archive/2008/11/30/3413317.aspx
      

  9.   

    <asp:TextBox ID="pid" runat="server" Text=' <%# Eval("P_id") >) %>'> </asp:TextBox> 
    看看吧。
      

  10.   

    那就是你没有绑定了,后台代码中page_load中有没有绑定
      

  11.   

            <asp:DetailsView ID="Pr_dtl" runat="server" BorderColor="Silver" BorderStyle="Outset"
                Height="85px" Width="574px" AutoGenerateRows="False">
                <Fields>
                   <asp:BoundField DataField="P_id" HeaderText="ID"/>            
                     <asp:BoundField DataField="P_name" HeaderText="NAME" />
                    <asp:BoundField DataField="P_type" HeaderText="TYPE" SortExpression="P_type" />
                    <asp:BoundField DataField="P_ttype" HeaderText="E-TYPE" SortExpression="P_ttype" />
                    <asp:BoundField DataField="P_link" HeaderText="LINk" />
                    <asp:ImageField DataImageUrlField="P_img1" HeaderText="IMAGE"> 
                        <ControlStyle Height="356px" Width="500px" />
                    </asp:ImageField>            
                </Fields>
                <FieldHeaderStyle Width="200px" HorizontalAlign="Center" />
            </asp:DetailsView>
      

  12.   

    page_load有绑定吖!    protected void Page_Load(object sender, EventArgs e)
        {        
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
            if (!this.IsPostBack)
            {            this.Bind();
                       }
        }
      

  13.   

        private void Bind()
        {
            String P_id = Request.QueryString["P_id"].ToString();
            SqlConnection con = Dcon.createConnection();
            SqlDataAdapter sda = new SqlDataAdapter();
            sda.SelectCommand = new SqlCommand("select *, '../../'+P_img as P_img1 from Product where P_id='" + P_id + "'", con);
            DataSet ds = new DataSet();
            sda.Fill(ds, "pro");
            this.Pr_dtl.DataSource = ds.Tables["pro"];
            this.Pr_dtl.DataBind();
        }
      

  14.   


    是这道理  你那个textbox 都不是在gridview的模板列里头 你绑定了也不会显示出来值啊
      

  15.   

    还在用这么老套的办法实现这些功能
    都什么年代了,用objectdatasource