中继器在许多表中显示相同的值

时间:2018-10-04 08:43:11

标签: sql asp.net sql-server webforms asprepeater

很抱歉,我的文章和英语不好,我是stackoverflow的新手。

我在联合表中写了一个复杂的SQL注释,该表也包含许多表。

当我执行查询时,它返回正确的数据。我在转发器中使用此视图。它显示了ManytoMany表中的相同值。我已经尝试了一切,但无法解决我的问题。希望您能理解我的意思。我添加了代码和结果。

SELECT   ROW_NUMBER() OVER (ORDER BY secID,ListID,ord) ROW_NUM, *
FROM  (SELECT        dbo.MotorList.section_id AS 'secId' ,dbo.MDIsignal.name AS Sname, dbo.MotorList.mList_id AS 'ListID', dbo.MotorType.name AS Type, dbo.Project.project_id, dbo.Section.code, dbo.MotorList.Mindex AS 'Index', dbo.MotorList.stat AS 'Stat', dbo.MotorList.description

FROM            dbo.MDI INNER JOIN
                         dbo.MDIsignal ON dbo.MDI.mDIsgnl_id = dbo.MDIsignal.mDIsgnl_id INNER JOIN
                         dbo.MotorList ON dbo.MDI.mList_id = dbo.MotorList.mList_id INNER JOIN
                         dbo.Section ON dbo.MotorList.section_id = dbo.Section.section_id INNER JOIN
                         dbo.Project ON dbo.Section.project_id = dbo.Project.project_id INNER JOIN
                         dbo.MotorType ON dbo.MotorList.motor_id = dbo.MotorType.motor_id
  UNION 
SELECT        dbo.MotorList.section_id AS 'secId' ,dbo.MDOsignal.name AS Sname, dbo.MotorList.mList_id AS 'ListID', dbo.MotorType.name AS 'Type', dbo.Project.project_id, dbo.Section.code, dbo.MotorList.Mindex AS 'Index', dbo.MotorList.stat AS 'Stat', dbo.MotorList.description 

FROM        dbo.MDO INNER JOIN
                         dbo.MDOsignal ON dbo.MDO.mDOsgnl_id = dbo.MDOsignal.mDOsgnl_id INNER JOIN
                         dbo.MotorList ON dbo.MDO.mList_id = dbo.MotorList.mList_id INNER JOIN
                         dbo.Section ON dbo.MotorList.section_id = dbo.Section.section_id INNER JOIN
                         dbo.Project ON dbo.Section.project_id = dbo.Project.project_id INNER JOIN
                         dbo.MotorType ON dbo.MotorList.motor_id = dbo.MotorType.motor_id
)a

Here correct values that return SQL

这是我绑定中继器以查看的方式:

        var list = db.SignalList_S.Where(a => a.secId == sec_id).ToList();
        RptListe.DataSource = list;
        RptListe.DataBind();

Here what shows repeater same values

我标记了一些值以使其更容易显示。

0 个答案:

没有答案