如何根据条件绑定网格视图中的数据

时间:2014-08-02 06:24:15

标签: c# asp.net gridview

我有暂停数据集

ActualMachineId BlockScheduleVersionId  ActualStartDate ActivityId  BlockScheduleActivityId BLOCKNO 

UT13-PM-4   UT2-BSV-14  13/08/2014  UT13-ACT-11 UT2-BSA-2   2284    
UT13-PM-4   UT2-BSV-6   08/06/2014  UT13-ACT-11 UT2-BSA-3   6396    
UT13-PM-5   UT2-BSV-5   12/08/2014  UT13-ACT-11 UT2-BSA-4   1239    
UT13-PM-5   UT2-BSV-7   12/08/2014  UT13-ACT-11 UT2-BSA-5   2277    
UT13-PM-4   UT2-BSV-8   08/06/2014  UT13-ACT-11 UT2-BSA-6   1239    
UT13-PM-3   UT2-BSV-9   21/08/2014  UT13-ACT-11 UT2-BSA-8   2283    

如果我绑定了数据,我也会得到所有重复的记录但是我不想要像我一样需要网格视图。在上面的设置中,块nos将从一行到另一行不同如果保留所有记录通过将cama(,)像fallows

分开,然后阻止no将在单行中
ActualMachineId BlockScheduleVersionId  ActualStartDate ActivityId  BlockScheduleActivityId BLOCKNO MachineName ActivityName
UT13-PM-4   UT2-BSV-14  13/08/2014  UT13-ACT-11 UT2-BSA-2   2284,6396       
UT13-PM-5   UT2-BSV-5   12/08/2014  UT13-ACT-11 UT2-BSA-4   1239,2277       
UT13-PM-4   UT2-BSV-8   08/06/2014  UT13-ACT-11 UT2-BSA-6   1239    
UT13-PM-3   UT2-BSV-9   21/08/2014  UT13-ACT-11 UT2-BSA-8   2283    

请帮我提一下建议。可以通过创建基于数据集的动态数据表来做。如果可以,那么怎么办

这是我尝试检查之前已声明3个隐藏标签的值的方法。

 if (e.Row.RowType == DataControlRowType.DataRow)
        {
            bool flag = false;
            string strBlockNos = lblBlockNos.Text;
            Label lblActualMachineId = (Label)e.Row.FindControl("lblActualMachineId");
            Label lblActivityId = (Label)e.Row.FindControl("lblActivityId");
            Label lblActualStartDate = (Label)e.Row.FindControl("lblActualStartDate");
            Label lblBlocks = (Label)e.Row.FindControl("lblBlocks");
            if (lblActualMachineId.Text == lblMachineId.Text)
            {

                if (lblActivityId.Text == lblActivityhidden.Text)
                {

                    if (lblActualStartDate.Text == lblStartDate.Text)
                    {

                        strBlockNos += lblBlocks.Text + ",";
                    }
                    else
                    {
                        lblMachineId.Text = lblActualMachineId.Text;
                        lblActivityhidden.Text = lblActivityId.Text;
                        lblStartDate.Text = lblActualStartDate.Text;
                        flag = true;
                    }
                }
                else
                {
                    lblMachineId.Text = lblActualMachineId.Text;
                    lblActivityhidden.Text = lblActivityId.Text;
                    lblStartDate.Text = lblActualStartDate.Text;
                    flag = true;
                }
            }
            else
            {
                lblMachineId.Text = lblActualMachineId.Text;
                lblActivityhidden.Text = lblActivityId.Text;
                lblStartDate.Text = lblActualStartDate.Text;

                flag = true;
            }
            if (flag == false)
            {
                e.Row.Visible = false;
            }
            else
            {
                //Here I need to update the previous row
            }
        }

提前感谢。

0 个答案:

没有答案