Source Code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ScrollGrid.aspx.cs" Inherits="ScrollGrid" %>
<!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>
<style type="text/css">
.scr
{
overflow-y: scroll;overflow-x:hidden; height: 200px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
<div class="scr" >
<asp:GridView ID="GridView1" runat="server" Font-Size="12px" BackColor="#FFFFFF"
GridLines="Both" CellPadding="4" Width="560">
<HeaderStyle BackColor="#EDEDED" Height="26px" />
</asp:GridView>
</div>
</div>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ScrollGrid.aspx.cs" Inherits="ScrollGrid" %>
<!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>
<style type="text/css">
.scr
{
overflow-y: scroll;overflow-x:hidden; height: 200px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
<div class="scr" >
<asp:GridView ID="GridView1" runat="server" Font-Size="12px" BackColor="#FFFFFF"
GridLines="Both" CellPadding="4" Width="560">
<HeaderStyle BackColor="#EDEDED" Height="26px" />
</asp:GridView>
</div>
</div>
</form>
</body>
</html>
Design
C# Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class ScrollGrid : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("server=Satya\\11;database=linku;uid=sa;pwd=satya123");
SqlDataAdapter da;
SqlCommand com;
DataSet ds;
DataTable dt;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
FillGrid();
}
}
public void FillGrid()
{
string sel = "Select * from student";
if (con.State == ConnectionState.Open)
{
con.Close();
}
con.Open();
da = new SqlDataAdapter(sel, con);
dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class ScrollGrid : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("server=Satya\\11;database=linku;uid=sa;pwd=satya123");
SqlDataAdapter da;
SqlCommand com;
DataSet ds;
DataTable dt;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
FillGrid();
}
}
public void FillGrid()
{
string sel = "Select * from student";
if (con.State == ConnectionState.Open)
{
con.Close();
}
con.Open();
da = new SqlDataAdapter(sel, con);
dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
No comments:
Post a Comment