Posted by : Anwar Hossain
Category : How to use grid view in asp.net c#

How to scroll gird view overflow data in asp.net c#

Dear viewers I will Show to scroll asp.net grid view control when data is greater than the width and height of grid view control. So wait to see a scroll grid view over flow data. Here just input a div and define the height width and overflow scroll-style properties in inline css.

Scroll Gridview overflow data ASP.NET C#

HTML

<div id="ScroolDiv" style="overflow: scroll; height:  300px; width: 280px;">
<asp:GridView ID="grdStudentList" runat="server" AutoGenerateColumns="False" BackColor="White"
BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal"
Width="400px" Height="400">
<AlternatingRowStyle BackColor="#F7F7F7" />
<Columns>
<asp:BoundField HeaderText="StudentName" DataField="StudentName" ItemStyle-HorizontalAlign="Center" />
<asp:BoundField HeaderText="Student Age" DataField="Address" ItemStyle-HorizontalAlign="Center" />
<asp:BoundField HeaderText="Student Address" DataField="Address" ItemStyle-HorizontalAlign="Center" />
</Columns>
<FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
<RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
<SortedAscendingCellStyle BackColor="#F4F4FD" />
<SortedAscendingHeaderStyle BackColor="#5A4C9D" />
<SortedDescendingCellStyle BackColor="#D8D8F0" />
<SortedDescendingHeaderStyle BackColor="#3E3277" />
</asp:GridView>
</div>

NAMESPACES

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

Code-behind

public partial class TestDesign_Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
 
if (!IsPostBack)
{
 
  LoadAllStudent();
 
}
 
}
private void LoadAllStudent()
{
 
List<Student> list = new List<Student>();
list.Add(new Student("Samim", 39,"Dhaka"));
list.Add(new Student("Asad", 48,"Chittagong"));
list.Add(new Student("Nayed", 39,"Sylhet"));
list.Add(new Student("Anwar", 48,"Sariatpur"));
grdStudentList.DataSource = list;
grdStudentList.DataBind();
 
 
}
 
//I have created Student class
 
public class Student
{
 
public Student(string StudentName, int StudentAge, string Address)
{
 
  _StudentName = StudentName;
  _StudentAge = StudentAge;
  _Address = Address;
 
 
}
 
private string _Address;
 
public string Address
{
  get { return _Address; }
  set { _Address = value; }
}
 
 
private int _StudentAge;
 
public int StudentAge
{
   get { return _StudentAge; }
  set { _StudentAge = value; }
}
 
private string _StudentName;
 
public string StudentName
{
  get { return _StudentName; }
  set { _StudentName = value; }
}
 
 
}
}

Out Put

grid_view_over_flow_data



Realted Article Headline

Gridview datetime format example in ASP.Net c#
Displaying total column value in the Gridview Footer using asp.net c#.
How to create grid view paging in asp.net using c#
How to bind Multi-Dimensional Arrays Data to gird view in asp.net using C#
How to bind Two-Dimensional Arrays Data to gird view in asp.net using C#
How to bind Single-Dimensional Arrays Data to gird view in asp.net using C#
how to export gridview data to pdf in asp.net c#
how to export gridview data to word in asp.net using c#
how to export gridview data to excel in c#
How to delete row from grid view showing confirmation JavaScript using asp.net c#
How to delete data from grid view using row deleting event in asp.net c#
How to bind data into gridview using code behind in asp.net c#
How to scroll gird view overflow data in asp.net c#
How to Bind data into grid view control using asp.net c#

Article Category

How to create asp.net control dynamically
Learn HTML for beginner
DataList example in C Sharp
Mail sending in asp.net c#
State Management in ASP C #
Basic sql tutorial for Beginner
DataTable example in ASP.Net C#
How to use LINQ in ASP.NET C#
asp.net c # basic tutorial
How to use ajax toolkit in asp.net C#
How to use different types of validation control using asp.net c#
How to use grid view in asp.net c#
Protected by Copyscape Online Plagiarism Detection