在c#.net中根据原因显示问题 [英] Show Question according Couse in c#.net

查看:62
本文介绍了在c#.net中根据原因显示问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..朋友,我有一个表,其中有两列Course_Name和Question_Name,具有
喜欢

Hi.. Friends I have a table having two column course_Name and question_Name having
like

course_Name  question_Name 

ASP.Net     What is ASP .Net ?
ASP.Net     What is State Management ?
ASP.Net     What is Session ?
Java        Difference Between Java & ASP.net ?
Java        Is here multiple inheritance in Java ?


我想在default.aspx页面上显示结果..


I wants to display result on my default.aspx page..

ASP.Net

What is ASP .Net ?
What is State Management ?
What is Session ?

Java   
   
Difference Between Java & ASP.net ?  
Is here multiple inheritance in Java ?


有谁请帮助我,如何使用asp.net中的任何控件来获取此信息.

请帮帮我.

谢谢&问候
Parveen Rathi


is anybody please help me how can I get this, using any control in asp.net.

Please help me.

Thanks & Regards
Parveen Rathi

推荐答案

如果您的页面只有两个课程名称,则可以使用以下两个查询
If your page has only two course names you can use following two queries
SELECT question_Name FROM TableName WHERE course_Name="Asp.Net"
SELECT question_Name FROM TableName WHERE course_Name="Java"


否则,您可以使用单独的方法来获取以下格式化的输出


otherwise you can use separate method to get following formatted output

string[] s= (FROM TableName SELECT DISTINCT course_name);
//linq code for retrieve distinct courses
foreach(str in s){
getOutput(str);
}


string getOutput(string course){ 
string output=course+"\n";
string[] s=(FROM TableName 
            WHERE course_Name=course
            SELECT question_Name);
foreach(str in s){
output+=str+"\n";
}
return output;
}


这不是确切的代码,但希望您能从中获得一些想法...


This is not exact code but hope you can get some idea from this...


检查此

您可以使用LINQ组联接.见下面的链接

http://social.msdn.microsoft.com /forums/zh-CN/linqprojectgeneral/thread/e6fcc00c-1f2a-4f29-9d7e-32f14323cb5a/ [ http://www.dotnetlogix.com/article/LINQ/111/Group- join-in-LINQ.html [ ^ ]
You can use LINQ group join. See below links

http://social.msdn.microsoft.com/forums/en-US/linqprojectgeneral/thread/e6fcc00c-1f2a-4f29-9d7e-32f14323cb5a/[^]

http://www.dotnetlogix.com/article/LINQ/111/Group-join-in-LINQ.html[^]


这篇关于在c#.net中根据原因显示问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆