请提供asp.net代码

编程入门 行业动态 更新时间:2024-10-23 09:34:13
本文介绍了请提供asp代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有三个表,课程,教师,学生.我已经使用主键约束&来实现表之间的一对多关系.外键约束.我的设计由一个组合框和一个组合框组成.两个datagridviews.我将课程表的公共列绑定到combobox.当我选择combobox项时,它将在一个gridvie&中显示相应的教员表记录.在另一个gridview中的学生表记录.这些仅在窗体加载中.我在C#Windows窗体中得到结果.给定代码billow.但是在ASP中我没有得到相同的结果.为此,请给asp完整代码.使用关系概念. 私有void Form1_Load(对象发送者,EventArgs e) { 字符串cs ="uid = sa; pwd = nanda; database = satyadatabase"; SqlConnection conn =新的SqlConnection(cs); //conn.Open(); SqlCommand cmd1 =新的SqlCommand("select * from course",conn); SqlCommand cmd2 =新的SqlCommand("select * from faculty",conn); SqlCommand cmd3 =新的SqlCommand("select * from student",conn); SqlDataAdapter da2 =新的SqlDataAdapter(cmd); SqlDataAdapter da1 =新的SqlDataAdapter(cmd4); SqlDataAdapter da3 =新的SqlDataAdapter(cmd3); DataSet ds = new DataSet(); da1.Fill(ds,"coursenew"); da2.Fill(ds,"facultynew"); da3.Fill(ds,"studentnew"); ds.Relations.Add("coursefac",ds.Tables ["coursenew"].Columns ["courseid"],ds.Tables ["facultynew"].Columns ["courseid"]); ds.Relations.Add("coursest",ds.Tables ["coursenew"].Columns ["courseid"],ds.Tables ["studentnew"].Columns ["courseid"]); comboucname.DataSource = ds.Tables ["coursenew"]; comboucname.DisplayMember =课程名称"; gridfaculty.DataSource = ds.Tables ["coursenew"]; gridfaculty.DataMember ="coursefac"; gridstudent.DataSource = ds.Tables ["coursenew"]; gridstudent.DataMember =课程"; } [edit]仅标记-OriginalGriff [/edit]

I have three tables course,faculty,student.I have implemented one to many relation between tables using primary key constraint & foreign key constraint.my design consists of one combobox & two datagridviews.I bind the common column of course table to combobox.when i select the combobox item it will display corresponding faculty table records in one gridvie & student table records in another gridview.these are in form load only.I get the result in C# Windows forms.given the code billow.but i am not getting same result in ASP.For this give asp full code.please use relations concept. private void Form1_Load(object sender, EventArgs e) { string cs = "uid=sa;pwd=nanda;database=satyadatabase"; SqlConnection conn = new SqlConnection(cs); // conn.Open(); SqlCommand cmd1 = new SqlCommand("select * from course", conn); SqlCommand cmd2 = new SqlCommand("select * from faculty", conn); SqlCommand cmd3 = new SqlCommand("select * from student", conn); SqlDataAdapter da2 = new SqlDataAdapter(cmd); SqlDataAdapter da1 = new SqlDataAdapter(cmd4); SqlDataAdapter da3 = new SqlDataAdapter(cmd3); DataSet ds = new DataSet(); da1.Fill(ds, "coursenew"); da2.Fill(ds, "facultynew"); da3.Fill(ds, "studentnew"); ds.Relations.Add("coursefac", ds.Tables["coursenew"].Columns["courseid"], ds.Tables["facultynew"].Columns["courseid"]); ds.Relations.Add("coursest", ds.Tables["coursenew"].Columns["courseid"], ds.Tables["studentnew"].Columns["courseid"]); comboucname.DataSource = ds.Tables["coursenew"]; comboucname.DisplayMember = "coursename"; gridfaculty.DataSource = ds.Tables["coursenew"]; gridfaculty.DataMember = "coursefac"; gridstudent.DataSource = ds.Tables["coursenew"]; gridstudent.DataMember = "coursest"; } [edit]Tags only - OriginalGriff[/edit]

推荐答案

您为什么希望我为您做功课?如果您遇到特定问题 ,请询问该问题. "Gimme codez"是疏远这里任何人的最好方法... Why would you expect me to do your homework for you? If you have a specific problem, please ask about it. "Gimme codez" is the best way to alienate anybody here...

添加到OriginalGriff所说的内容- 这是询问者的期望: 1. 先尝试您要做什么! 2.制定看起来像问题/无法解决的问题. 尝试一下,告诉您是否遇到问题. 成员将很乐意为您提供帮助. 看起来您说的是Winforms工作代码,但是无法在Webforms中工作?您认为两者的差异在哪里发生? Adding to what OriginalGriff said - Here is what is expected by enquirers: 1. TRY first what you want to do! 2. Formulate what was done by you that looks like an issue/not working. Try them and tell if you face issues. Members will be more than happy to help like this. Looks like you have a Winforms working code as you say and yet you are unable to get things working in Webforms? Where do you think the difference happens in both?

更多推荐

请提供asp.net代码

本文发布于:2023-11-11 07:01:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1577707.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:代码   asp   net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!