0% found this document useful (0 votes)
45 views3 pages

Default Aspx Page: Using Using Using Using Using Using Using Using

This document contains code for a default ASPX page. It includes code to insert student data into a database table on button click, including textboxes for roll number, name, mobile number, and email. It also includes a dropdown list for class and retrieves and displays the student data in a grid view. On page load, it clears any existing text in the textboxes.

Uploaded by

Shreeya Shirke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views3 pages

Default Aspx Page: Using Using Using Using Using Using Using Using

This document contains code for a default ASPX page. It includes code to insert student data into a database table on button click, including textboxes for roll number, name, mobile number, and email. It also includes a dropdown list for class and retrieves and displays the student data in a grid view. On page load, it clears any existing text in the textboxes.

Uploaded by

Shreeya Shirke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

ICLES MOTILAL JHUNJHUNWALA COLLEGE OF SCIENCE ,ARTS AND COMMERCE

DEFAULT ASPX PAGE:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

public partial class _Default : System.Web.UI.Page


{
public void refresh()
{
TextBox1.Text = "";
TextBox2.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";

}
protected void Page_Load(object sender, EventArgs e)
{

}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString="Data Source=LABSERVER\\SQLEXPRESS;Initial
Catalog=TYIT;Integrated Security=True";
con.Open();
string rr=TextBox1.Text;
string ra=TextBox2.Text;
string rb=DropDownList1.Text;
string rc=TextBox4.Text;
string rd=TextBox5.Text;

SqlCommand cmd=new SqlCommand("insert into


stud38(Roll,Name,Class,Mobile,EmailId)
values('"+rr+"','"+ra+"','"+rb+"','"+rc+"','"+rd+"')",con);

cmd.ExecuteNonQuery();

con.Close();
refresh();
GridView1.DataBind();

} }
ICLES MOTILAL JHUNJHUNWALA COLLEGE OF SCIENCE ,ARTS AND COMMERCE

DEFAULT ASPX PAGE:


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div style="font-weight: 700">

rollno:&nbsp;
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
name:
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
class:
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>fyit</asp:ListItem>
<asp:ListItem>syit</asp:ListItem>
<asp:ListItem>tyit</asp:ListItem>
</asp:DropDownList>
<br />
Mobile no:
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
<br />
emailid
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="submit" />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" EnableModelValidation="True">
<Columns>
<asp:BoundField DataField="Roll" HeaderText="Roll" SortExpression="Roll"
/>
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name"
/>
<asp:BoundField DataField="Class" HeaderText="Class"
SortExpression="Class" />
<asp:BoundField DataField="Mobile" HeaderText="Mobile"
SortExpression="Mobile" />
<asp:BoundField DataField="EmailId" HeaderText="EmailId"
SortExpression="EmailId" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:TYITConnectionString %>"
SelectCommand="SELECT * FROM [stud38]"></asp:SqlDataSource>

</div>
</form>
</body>
</html>
ICLES MOTILAL JHUNJHUNWALA COLLEGE OF SCIENCE ,ARTS AND COMMERCE

OUTPUT:

You might also like