本文介绍了根据另一个表的值在gridview中显示值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有两张桌子: 主题表格: dept | sem |主题 EC | 4 |物理学 EC | 4 |化学 EC | 5 |英语 标记表格: dept | sem | rollno | name |主题|标记 EC | 4 | 1 | abc |物理| 80 EC | 4 | 2 | xyz |物理| 95 EC | 4 | 1 | abc |化学| 90 EC | 4 | 2 | xyz |化学| 85 我预期的输出在gridview中就像: (根据sem值从主题表中检索主题名称(sem 4-physics,chemistry; sem 5-英语等等..) dept | sem | rollno | name | physics | chemistry | total EC | 4 | 1 | abc | 80 | 90 | 170 EC | 4 | 2 | xyz | 95 | 85 | 170 当我使用如下查询时,: 选择rollno,名称,标记为物理来自标记,其中subject ='physics' i完美地得到它作为我的expec atation。,但是,我想使用c#。在asp.net网页的gridview中显示输出,那么如何为多列值(物理,化学)做到这一点?我搜索了很多网站,但是,我仍然没有任何明确的想法。我应该使用SQL QUERY或GRIDVIEW功能来实现我的目标吗?如果是这样的功能又如何?请帮助。解决方案 i have two tables:"subject" table:dept | sem | subjectEC | 4 | physicsEC | 4 | chemistryEC | 5 | english"marks" table:dept | sem | rollno|name | subject | marksEC | 4 | 1 | abc | physics | 80 EC | 4 | 2 | xyz | physics | 95 EC | 4 | 1 | abc | chemistry| 90 EC | 4 | 2 | xyz | chemistry| 85 my expected "output" in the gridview is like:(the subject names are retrieved from the subject table based on the "sem" values(sem 4-physics,chemistry;sem 5- english and so..) dept| sem | rollno|name | physics | chemistry | totalEC | 4 | 1 | abc | 80 | 90 | 170EC | 4 | 2 | xyz | 95 | 85 | 170when i use a query like:select rollno,name,marks as physics from marks where subject='physics'i get it perfectly as my expecatation.,but, i want to display the output in a gridview in asp.net webpage using c# .,so how can do this for multiple column values(physics,chemistry)? I searched many websites,but, still im not having any clear idea.should i acheive my goal using SQL QUERY OR GRIDVIEW FEATURES? if so what features and how? pls help. 解决方案 这篇关于根据另一个表的值在gridview中显示值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-14 05:25