请提供asp.net代码 [英] Please give asp.net code

查看:65
本文介绍了请提供asp.net代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个表,课程,教师,学生.我已经使用主键约束&来实现表之间的一对多关系.外键约束.我的设计由一个组合框和一个组合框组成.两个datagridviews.我将课程表的公共列绑定到combobox.当我选择combobox项时,它将在一个gridvie&中显示相应的教员表记录.在另一个gridview中的学生表记录.这些仅在窗体加载中.我在C#Windows窗体中得到结果.给定代码billow.但是在ASP.net中我没有得到相同的结果.为此,请给asp.net完整代码.使用关系概念.

私有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.net.For this give asp.net 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代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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