Click here to Skip to main content
15,905,683 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted
Updated 10-May-11 7:46am
v3
Comments
Sergey Alexandrovich Kryukov 10-May-11 14:22pm    
Where is your question?
--SA
dedoooo 10-May-11 14:43pm    
what is the technique that help me to transfer to specific schedule?
dedoooo 10-May-11 17:51pm    
If my qustion is not clear please tell me

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 + "'";
 
Share this answer
 
v2
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.
 
Share this answer
 
Comments
dedoooo 14-May-11 5:45am    
thanks
but , why need update the time of the schedule?

the scheduules and their time is already stored in the data base.

I mean just by the Id of the sudent can open other page with the details of the schedule

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900