Sumathi

Sumathi

  • 1.2k
  • 234
  • 732

Displaying student details after logging in to student portal

Mar 28 2024 12:14 PM

I need the details of the student to get displayed when they click on detail button. Right now just the design is getting displayed but the student's details is not appearing. The student logins using regno. Here is the code for detail.aspx.cs page: 
 

SqlConnection cn = new SqlConnection("Data Source=DESKTOP-UIGAOQI\\SQLEXPRESS;Initial Catalog=mydb;Integrated Security=True;");
    protected void Page_Load(object sender, EventArgs e)
    {
                
        string i, s;
                i = System.Convert.ToString(Application["uid"]);
                cn.Open();
                s = "select * from student where RegNo='" + i + "'";
                SqlCommand cmd1 = new SqlCommand(s, cn);
                SqlDataReader rs = cmd1.ExecuteReader();
                while (rs.Read())
                {
                    if (rs.GetString(6) == i)
                    {
                        //regno.Text = rs.GetString(6);
                        name.Text = rs.GetString(0);
                        std.Text = rs.GetString(1);
                        mob.Text = rs.GetString(2);
                        add.Text = rs.GetString(5);
                        dob.Text = rs.GetString(3);
                        gen.Text = rs.GetString(4);

                    }
                }
                cn.Close();
    }

After logging in, the main page that contains links to detail,attandance and marks page would be displayed. When the display button is clicked, it redirects to the detail.aspx page which is designed as: 
 

<body>
    <center>
    <form id="form1" runat="server">
    <div style="height:510px">
   <table style="width:700px; height:390px; background-color:#ADD8E6;" align="center">
       <tr>
          <td align="center" width="50%" colspan="2">
             <h1>STUDENT DETAILS</h1><hr />
          </td>                  
       </tr>
       <tr>
          <td align="center" width="25%" class="style8">
            <h4>Name:</h4>         
          </td>    
          <td width="25%" class="style8">
              <asp:TextBox ID="name" runat="server"></asp:TextBox>
          </td>                  
       </tr>
       <tr>
          <td align="center" width="25%">
            <h4>Class:</h4>
          </td>    
          <td width="25%">
            <asp:TextBox ID="std" runat="server"></asp:TextBox>
          </td>                  
       </tr>
       <tr>
          <td align="center" width="25%">
             <h4>Contact:</h4>
          </td>    
          <td width="25%">
            <asp:TextBox ID="mob" runat="server"></asp:TextBox>
          </td>                  
       </tr>
       <tr>
       <td align="center" width="25%">
       <h4>DOB:</h4>
       </td>
       <td width="25%">
           <asp:TextBox ID="dob" runat="server"></asp:TextBox>
       </td>
       </tr>
       <tr>
          <td align="center" width="25%">
            <h4>Gender:</h4>
          </td>    
          <td width="25%">
              <asp:TextBox ID="gen" runat="server"></asp:TextBox>
          </td></tr>
       <tr>
          <td align="center" width="25%">
            <h4>Address:</h4>
          </td>    
          <td width="25%">
             <asp:TextBox ID="add" runat="server"></asp:TextBox>
          </td>                  
       </tr>
       <tr>
          <td align="center" width="25%">
            <h4>RegNo:</h4>
          </td>    
          <td width="25%">
              <asp:TextBox ID="regno" runat="server"></asp:TextBox>
          </td></tr>
       <tr>
          <td align="center" width="50%" colspan="2">
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <asp:Button ID="Button2" runat="server" Text="Back" Font-Bold="True" 
                  ForeColor="Black" Height="36px" onclick="Button2_Click" Width="88px"
                  PostBackUrl="~/student/student.aspx" />
          </td>    
                         
       </tr>
       <tr>
          <td align="center" width="50%" colspan="2">
              &nbsp;</td>    
                       
       </tr>
   </table>
</div>

    </form>
    </center>

</body>

What do i change to display the student's details?


Answers (2)