ASPX.CS Code
.CS Code (Class file)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Linq.Mapping;
[Table(Name = "stu_info")]
public class Person
{
[Column(IsPrimaryKey
= true, IsDbGenerated = true)]
public int roll { get; set; }
[Column]
public string Name { get; set; }
[Column]
public string LName { get; set; }
}
ASPX CODE
<%@ 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>
</div>
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Linq.Mapping;
using System.Data;
using System.Data.Linq;
using System.Data.SqlClient;
public partial class _Default :
System.Web.UI.Page
{
//BusinessObjects
db = new BusinessObjects();
public string constr = @"Data
Source=RAMUTELECOM\RKUMAR;Initial Catalog=test3;Persist Security Info=True;User
ID=sa;Password=mysachi";
protected void Page_Load(object
sender, EventArgs e)
{
DataContext
db = new DataContext(constr);
GridView1.DataSource = db.GetTable<Person>().ToList();
GridView1.DataBind();
}
protected void Button1_Click(object
sender, EventArgs e)
{
SqlConnection
con = new SqlConnection(constr);
SqlCommand
com = new SqlCommand("exec sp_twotable", con);
con.Open();
SqlDataReader
dr = com.ExecuteReader();
GridView1.DataSource = dr;
GridView1.DataBind();
dr.NextResult();
GridView2.DataSource = dr;
GridView2.DataBind();
con.Close();
}
}
0 comments:
Post a Comment