通过一条查询语句返回如下数据: 
    
   
   
   我想在后台对查询出来数据做下处理..   然后绑定repeater 其中step_number,dept_name只显示一条就OK 了..
   序号对应的是step_number,工序对应的是dept_name,说明是由parameter_desc和parameter_value组合而成,
   要实现效果如下:
   

解决方案 »

  1.   

    两种方法:
    1.在数据库中,用存储过程实现
    2.在上层,处理datatable,进行合并
      

  2.   


     请问在DataTabel 要怎么实现..昨天试过了..没达到效果..
      

  3.   

    不知道能不能用sql语句处理,感觉是可行的
      

  4.   

       是用的储存过程,里面不好去改..所以想在返回的DateTable 中做处理...
      

  5.   

    javascript + HTML + css 不采用服务器控件
      

  6.   

    winform?
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace WindowsApplication119
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();            DataTable DT = new DataTable();
                DT.Columns.Add("c1");
                DT.Columns.Add("c2");
                DT.Columns.Add("c3");            DT.Rows.Add(new Object[] { 1, 2, 3 });
                DT.Rows.Add(new Object[] { 11, 22, 33 });            DataGridView DGV = new DataGridView();
                DGV.Parent = this;
                DGV.Dock = DockStyle.Fill;
                DGV.Columns.Add(new DataGridViewTextBoxColumn());
                DGV.CellFormatting += new DataGridViewCellFormattingEventHandler(DGV_CellFormatting);
                DGV.AutoGenerateColumns = false;
                DGV.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
                DGV.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders;
                DGV.DataSource = DT;
            }        void DGV_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
            {
                DataGridView DGV = (DataGridView)sender;
                DataTable DT = (DataTable)DGV.DataSource;
                if (e.RowIndex < DT.Rows.Count)
                    e.Value = DT.Rows[e.RowIndex]["c1"].ToString() + Environment.NewLine
                        + DT.Rows[e.RowIndex]["c2"].ToString() + Environment.NewLine
                        + DT.Rows[e.RowIndex]["c3"].ToString();
            }
        }
    }
      

  7.   

    给楼主一个sql参考,采用SQL递归查询配合虚拟表实现,在组合的时候我采用br分隔换行输出
    不过没有序号,所以可以下来把序号作为课题再研究下,个人认为那序号意义不大,那些参数都应该是并列定义,当然楼主也可以采用程序中处理Datatable表的方式解决上述问题。--建立测试环境
    create table materals
    (id int identity(1,1),
    step_number int ,
    dept_code varchar(20),
    dept_name nvarchar(50),
    parameter_desc nvarchar(200),
    parameter_value nvarchar(20) )insert into materals
    select '1','c05','cc','length','427.44*586.40mm' union
    select '1','c05','cc','depath','2.5+/-0.25mm' union
    select '1','c05','cc','other','no' union
    select '2','p01','bb','bbname','single' union 
    select '2','p01','bb','bbVision','DSR330'  
    --结束--运行下列递归查询
    with x(id,step_number,dept_code,dept_name,descn,cnt,length)
    as
    (
    select id,step_number,dept_code,dept_name,
    cast(parameter_desc+':'+parameter_value as varchar(400) )as descn ,
    count(*) over (partition by step_number) as cnt,1 as length
    from materals
    union all
    select r.id, r.step_number,r.dept_code,r.dept_name,
    cast(x.descn+'<br />'+r.parameter_desc+':'+r.parameter_value as varchar(400)), 
    x.cnt,x.length+1
    from materals r join  x on r.step_number=x.step_number and r.id>x.id
    )
    select step_number as '序号',dept_code as '工序',descn as '说明' from x where length=cnt
    --结束