Xtrareport如何绑定dataSet数据
1、report.datasource直接放一个dataset或datatable此种方法在代码里实现,直接为report赋数据源 特点: -无须生成xml -生成模板文件.repx中不包含表结构信息 -可用于特定表的使用,一旦将repx复制到其他地方,则无法根据repx生成表结构

3、public XtraReport1(DataTable dt) { InitializeComponent(); this.DataSource = dt; //这里面的Text是xrtable的属性 区分大小写

5、private void button1_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); string constr = "server=192.168.100.222;user=sa;pwd=p@ssw1rd;database=pwd1";

6、SqlConnection con = new SqlConnection(constr); try { con.Open(); SqlCommand com = new SqlCommand("select bid,bname,shuoming from book",con); SqlDataAdapter dpt = new SqlDataAdapter(com);

7、dpt.F坡纠课柩ill(dt); XtraReport1 report = new XtraReport1烫喇霰嘴(dt); report.Landscape = true; documentViewer1.DocumentSource = report; report.CreateDocument(); } catch (Exception) { throw; } }
