On page connection in asp.net with c#
On page connection in asp.net with c#:
ASP.NET gives you flexibility in how you connect to databases. please add the
follwoing code in you aspx page and check how to get connection on .aspx page.
Connection in asp.net in .aspx page with c#
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="onpageconnection.aspx.cs" Inherits="onpageconnection" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ import Namespace="System.Data" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
try
{
System.Data.SqlClient.SqlConnection con;
sqlconn objconn = new sqlconn();
con = objconn.getcon();
con.Open();
String str = "select * from EmpDemo";
//SqlCommand cmd = new SqlCommand(str,con);
//SqlDataReader adp;
SqlDataAdapter adp = new SqlDataAdapter(str,con);
DataSet ds = new DataSet();
adp.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
//Response.Write("connection open!!!!!!!");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
</script>
<html>
<head>
<title></title>
</head>
<body>
<form id="Form1" runat="server">
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</form>
</body>
</html>
Other Crystal Report related Post:
Here we give the list of Examples related to gridview:
- Show gridview Row Details.
- Templatefield in gridview
- Introduction of Asp.net grid view Control.
- Example of Templatefield in gridview .
- Example of DropDownList inside GridView
- Check box in ASP.NET GridView
- Ckeck box list example using javascript in grid.
- Check box in ASP.NET GridView
- Show grid view row details in to tooltip.
- How to Bind Grid view Form database.
- Show gridview Row Details And Give Example.
- Example of Template field.
- How to Bind Grid view Form database.
- Template field in asp.net grid view.
- Example of DropDownList inside GridView control
- Introduction of Asp.net grid view Control.
- Example of C# for Bind Data to asp.net Textbox inside gridview control
- Bind Data to asp.net textbox control in inside of gridview Using C# Example
Comments
Post a Comment