Professional Documents
Culture Documents
Student.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Student.aspx.vb"
Inherits="Student" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Student ID :
<asp:TextBox ID="txtStudID" runat="server" Width="147px"></asp:TextBox>
<br />
<br />
Student Name :
<asp:TextBox ID="txtSname" runat="server" Width="219px"></asp:TextBox>
<br />
<br />
Area :
<asp:TextBox ID="txtArea" runat="server" Width="181px"></asp:TextBox>
<br />
<br />
Mobile :
<asp:TextBox ID="txtMobile" runat="server" Width="184px"></asp:TextBox>
<br />
<br />
Email :
<asp:TextBox ID="txtEmail" runat="server" Width="188px"></asp:TextBox>
<br />
<br />
Study In :
<asp:TextBox ID="txtStudy" runat="server" Width="186px"></asp:TextBox>
<br />
<br />
<br />
<asp:Button ID="btnSubmit" runat="server" Text="SUBMIT" />
<asp:Button ID="btnReset" runat="server" Text="RESET" />
<br />
<br />
<br />
<br />
<asp:GridView ID="grd" runat="server" CellPadding="4" ForeColor="#333333"
GridLines="None" AutoGenerateDeleteButton="True"
AutoGenerateEditButton="true"
AutoGenerateColumns="true"
DataKeyNames="StudID"
OnRowEditing="OnRowEditing"
OnRowCancelingEdit="OnRowCancelingEdit"
OnRowUpdating = "OnRowUpdating"
OnRowDeleting = "RowDelete"
>
<AlternatingRowStyle BackColor="White" />
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center"
/>
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<SortedAscendingCellStyle BackColor="#FDF5AC" />
<SortedAscendingHeaderStyle BackColor="#4D0000" />
<SortedDescendingCellStyle BackColor="#FCF6C0" />
<SortedDescendingHeaderStyle BackColor="#820000" />
</asp:GridView>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</div>
</form>
</body>
</html>
Imports System.Data.SqlClient
Imports System.Data
Partial Class Student
Inherits System.Web.UI.Page
Dim strConnection As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=D:\College\
ASP.NET\2022\Website_B\DB2022.mdf;Integrated Security=True;Connect Timeout=30;User
Instance=True"
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
If IsPostBack = False Then
FillData()
End If
End Sub
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btnSubmit.Click
Dim cn As New SqlConnection(strConnection)
Dim cmd As New SqlCommand
Dim query As String
cn.Open()
query = "Insert into studMst values(" & txtStudID.Text & ",'" & _
txtSname.Text & "','" & txtArea.Text & "','" & _
txtMobile.Text & "','" & txtEmail.Text & "','" & _
txtStudy.Text & "')"
Query = "Delete from studMst where StudID=" & intCode & ""
Dim cn As New SqlConnection(strConnection)
Dim cmd As New SqlCommand
cn.Open()
cmd.CommandText = Query : cmd.Connection = cn
cmd.ExecuteNonQuery()
cmd.Dispose()
If cn.State = 1 Then cn.Close()
cn.Dispose()
grd.EditIndex = -1
FillData()
End Sub
End Class