USE [log] GO /****** Object: Table [dbo].[Department] Script Date: 02/24/2012 11:59:46 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[Department]( [id] [int] IDENTITY(1,1) NOT NULL, [department name] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ) ON [PRIMARY] GO SET ANSI_PADDING OFF USE [log] GO /****** Object: Table [dbo].[Student_S] Script Date: 02/24/2012 13:11:01 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[Student_S]( [id] [int] IDENTITY(1,1) NOT NULL, [Sid] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, [Firstname] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, [LastName] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, [Phone] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, [Department] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, CONSTRAINT [PK_Student_S] PRIMARY KEY CLUSTERED ( [Sid] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="gridscroll.aspx.cs" Inherits="gridscroll" %> <!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 id="Head1" runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <h2 style="color: blue; font-style: normal"> Gridview scrollbar in asp.net <br /> </h2> <div> <asp:DropDownList ID="ddlgrdbind" runat="server" OnSelectedIndexChanged="ddlgrdbind_SelectedIndexChanged" AutoPostBack="true"> <asp:ListItem Text="Select One" Value="Select"></asp:ListItem> <asp:ListItem Text="X" Value="X"></asp:ListItem> <asp:ListItem Text="Y" Value="Y"></asp:ListItem> </asp:DropDownList> <asp:Panel ID="pnlgrd" runat="server" ScrollBars="Vertical" Height="150px" Visible="false" Width="200px"> <asp:GridView ID="grdscrollbar" runat="server" Visible="false" Width="100px"> </asp:GridView> </asp:Panel> </div> </form> </body> </html>
using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient; public partial class gridscroll : System.Web.UI.Page { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Employee"].ToString()); DataSet ds = new DataSet(); protected void Page_Load(object sender, EventArgs e) { } protected void ddlgrdbind_SelectedIndexChanged(object sender, EventArgs e) { if (ddlgrdbind.SelectedItem.Value == "X") { pnlgrd.Visible = true; grdscrollbar.Visible = true; SqlCommand cmd = new SqlCommand("select * from Depatment", con); SqlDataAdapter sadp = new SqlDataAdapter(cmd); sadp.Fill(ds); grdscrollbar.DataSource = ds; grdscrollbar.DataBind(); } else if (ddlgrdbind.SelectedItem.Value == "Y") { pnlgrd.Visible = true; grdscrollbar.Visible = true; SqlCommand cmd = new SqlCommand("select * from login", con); SqlDataAdapter sadp = new SqlDataAdapter(cmd); sadp.Fill(ds); grdscrollbar.DataSource = ds; grdscrollbar.DataBind(); } } }
No comments:
Post a Comment