c#和asp.net中的学生时间表 [英] schedule of student in c# and asp.net

查看:64
本文介绍了c#和asp.net中的学生时间表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我有一个页面,其中包含学生名单及其信息
(学生姓名,学生证,学生级别)
我想如果我单击每个学生的姓名,则打开其他页面上有该学生的时间表.
我想知道什么技术可以帮助我转移到特定的时间表.
因为当我单击任何一个学生时,它为我列出了整个列表的相同时间表.
这是我第一页的代码:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
        DataSourceID="SqlDataSource1">
        <Columns>
            <asp:BoundField DataField="FIRST_NAME_A" HeaderText="FIRST_NAME_A" visible="false"
                SortExpression="FIRST_NAME_A" />
            <asp:BoundField DataField="FATHER_NAME_A" HeaderText="FATHER_NAME_A" visible="false"
                SortExpression="FATHER_NAME_A" />
            <asp:BoundField DataField="FAMILY_NAME_A" HeaderText="FAMILY_NAME_A" visible="false"
                SortExpression="FAMILY_NAME_A" />
            <asp:BoundField DataField="CURRENT_LEVEL" HeaderText="Level"
                SortExpression="CURRENT_LEVEL" />

                    <asp:TemplateField HeaderText="Name">
                    <ItemTemplate>
                        <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl=''<%# string.Format("sch.aspx?ID={0}{1}{2}", Eval("FIRST_NAME_A"), Eval("FATHER_NAME_A"), Eval("FAMILY_NAME_A")) %>''


                            Target="_blank" Text=''<%# Eval("FIRST_NAME_A") +""+  Eval("FATHER_NAME_A") +"" + Eval("FAMILY_NAME_A")%>''></asp:HyperLink>

                    </ItemTemplate>
                </asp:TemplateField>

            <asp:BoundField DataField="STUDENT_NO" HeaderText="IDStudent"
                SortExpression="STUDENT_NO" />

            <asp:TemplateField>
            <ItemTemplate>
            <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl=''<%# string.Format("sch.aspx?ID=", Eval("STUDENT_NO")) %>''
            Target="_blank" Text=''<%# Eval("STUDENT_NO")%>''></asp:HyperLink>
            </ItemTemplate>
            </asp:TemplateField>

        </Columns>
    </asp:GridView>



第二页的代码(我希望日程安排出现在该页上)

protected void Button1_Click(object sender, EventArgs e)
{
    string str = Request.QueryString["ID"];
    string s = "301063";

    //1)connection:
    String conStr = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents and Settings…";
    SqlConnection cn = new SqlConnection(conStr);

    //---------------------------------------------------//
    //2)request:
    SqlCommand cmd = new SqlCommand();
    cmd.Connection = cn;
    cmd.CommandType = CommandType.Text;
    cmd.CommandText = "SELECT COURSE_DEPARTMENT,COURSE_NO,SECTION_NO FROM TSENROLL ";
    cmd.CommandText += " INNER JOIN TSTUDENT ON TSENROLL.STUDENT_NO = TSTUDENT.STUDENT_NO WHERE TSENROLL.STSECTION_STUDENT_NO=''1400''";
    //---------------------------------------------------//
    //Open Connection1
    cn.Open();
    //---------------------------------------------------//

    SqlDataReader reader = cmd.ExecuteReader();
    GridView1.DataSource = reader;
    GridView1.DataBind();

    cn.Close();
}



感谢您的帮助. 应该是:

cmd.CommandText += " INNER JOIN TSTUDENT ON TSENROLL.STUDENT_NO = TSTUDENT.STUDENT_NO WHERE TSENROLL.STSECTION_STUDENT_NO=''" + str + "''";


您将需要编写一个更新查询,以更新您的计划时间.那应该转移您的Appoinrtment.另一种方法是删除表中的记录,然后在不同的时间再次插入.


Hi I have a page which have the list of student with their information included
( Student name , Student ID , Student level)
I want if I click on the name of each student open other page has the schedule of this student.
I want to know what is the technique that help me to transfer to specific schedule.
Because when I click on any student it gave me the same schedule for the whole list.
This is my code for the first page:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
        DataSourceID="SqlDataSource1">
        <Columns>
            <asp:BoundField DataField="FIRST_NAME_A" HeaderText="FIRST_NAME_A" visible="false"
                SortExpression="FIRST_NAME_A" />
            <asp:BoundField DataField="FATHER_NAME_A" HeaderText="FATHER_NAME_A" visible="false"
                SortExpression="FATHER_NAME_A" />
            <asp:BoundField DataField="FAMILY_NAME_A" HeaderText="FAMILY_NAME_A" visible="false"
                SortExpression="FAMILY_NAME_A" />
            <asp:BoundField DataField="CURRENT_LEVEL" HeaderText="Level"
                SortExpression="CURRENT_LEVEL" />

                    <asp:TemplateField HeaderText="Name">
                    <ItemTemplate>
                        <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl=''<%# string.Format("sch.aspx?ID={0}{1}{2}", Eval("FIRST_NAME_A"), Eval("FATHER_NAME_A"), Eval("FAMILY_NAME_A")) %>''


                            Target="_blank" Text=''<%# Eval("FIRST_NAME_A") +""+  Eval("FATHER_NAME_A") +"" + Eval("FAMILY_NAME_A")%>''></asp:HyperLink>

                    </ItemTemplate>
                </asp:TemplateField>

            <asp:BoundField DataField="STUDENT_NO" HeaderText="IDStudent"
                SortExpression="STUDENT_NO" />

            <asp:TemplateField>
            <ItemTemplate>
            <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl=''<%# string.Format("sch.aspx?ID=", Eval("STUDENT_NO")) %>''
            Target="_blank" Text=''<%# Eval("STUDENT_NO")%>''></asp:HyperLink>
            </ItemTemplate>
            </asp:TemplateField>

        </Columns>
    </asp:GridView>



This code for the second page ( that I want the schedule appear on it)

protected void Button1_Click(object sender, EventArgs e)
{
    string str = Request.QueryString["ID"];
    string s = "301063";

    //1)connection:
    String conStr = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents and Settings…";
    SqlConnection cn = new SqlConnection(conStr);

    //---------------------------------------------------//
    //2)request:
    SqlCommand cmd = new SqlCommand();
    cmd.Connection = cn;
    cmd.CommandType = CommandType.Text;
    cmd.CommandText = "SELECT COURSE_DEPARTMENT,COURSE_NO,SECTION_NO FROM TSENROLL ";
    cmd.CommandText += " INNER JOIN TSTUDENT ON TSENROLL.STUDENT_NO = TSTUDENT.STUDENT_NO WHERE TSENROLL.STSECTION_STUDENT_NO=''1400''";
    //---------------------------------------------------//
    //Open Connection1
    cn.Open();
    //---------------------------------------------------//

    SqlDataReader reader = cmd.ExecuteReader();
    GridView1.DataSource = reader;
    GridView1.DataBind();

    cn.Close();
}



thanks for ur help

解决方案

Why are you hardcoding the student_no in your database query...
it should be:

cmd.CommandText += " INNER JOIN TSTUDENT ON TSENROLL.STUDENT_NO = TSTUDENT.STUDENT_NO WHERE TSENROLL.STSECTION_STUDENT_NO=''" + str + "''";


You will need to write an update query that will update the time of your schedule. That should transfer your appoinrtment. Another way could be to delete the record in the table, and insert again with a different time.


这篇关于c#和asp.net中的学生时间表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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