我的表A(id,C1,C2)
请问怎样才能把id="1"的C2直接绑到TextBox1中?

解决方案 »

  1.   

    TextBox.Text = ds.Tables[0].Rows[0][0].ToString();前提是你ds的Table中,仅仅存放了一张表,一行列数据当然,如果是多数据的话,定义不同的Index就可以了
      

  2.   

    使用dataset,不需要代码,直接在属性datasource(还是哪里有点忘了)那里用向导生成就行了,具体的你要自己试,不需要写一行代码。
      

  3.   

    参见http://blog.csdn.net/Freeze_Soul/archive/2007/09/07/1775722.aspx。把AllowPaging设置为False。
      

  4.   

                            TextBox textboxstring = new TextBox();
                            textboxstring.ID = "test";
                            container.Controls.Add(textboxstring);
                            textboxstring.DataBinding += new EventHandler(textbox_DataBinding);         void textbox_DataBinding(object sender, EventArgs e)
            {
                TextBox textBox = (TextBox)sender;
                textBox.Text = "";  // 自己添加取数据库的逻辑 如果 container 是GridView 就取 textBox.NamingContainer.DataItem
            }