绑定DataTable一般都是使用SqlDataAdapter
SqlDataAdapter ad = new SqlDataAdapter("Sql语句",conn);
DataTable dt = new DataTable();
ad.Fill(dt);
用Read()的话你要判断是否为Null 可以用fi(DbNull.Value!=reader["列名"])判断
其实也可以直接用DataSet绑定reaper的数据源DataSource
using using System.Web.UI.HtmlControls;在你的table的位置放一个PlaceHolder然后,在查询按钮的代码里写:string 条件=" name='"+TextBox1.Text+"' and ....."; //用你的textbox构造起来的sql查询条件string sql="select * from 表 where "+ 条件; //查询的sql语句2842DataTable dt = new DataTable();SqlConnection conn = new SqlConnection("数据库连接字符串");conn.Open();SqlDataAdapter da = new SqlDataAdapter(sql, conn); ;da.Fill(dt);conn.Close();Table t=new Table();for (int i = 0; i < dt.Rows.Count; i++){ TableRow r = new TableRow(); TableCell c = new TableCell(); c.Text = dt.Rows[i][0].ToString(); r.Cells.Add(c); t.Rows.Add(r);}PlaceHolder1.Controls.Add(t);