SlideShare a Scribd company logo
GridView control
A recurring task in software development is to display tabular data. ASP.NET provides a number
of tools for showing tabular data in a grid, including the GridView control. With
the GridView control, you can display, edit, and delete data from many different kinds of data
sources, including databases, XML files, and business objects that expose data.
To add a GridView control to a page
 Drag the GridView control from the Toolbox task pane to your page.
After you add a GridView control, you can specify a data source for the control.
To bind the GridView control to a data source
1. In Design view, right-click the GridView control, and then click Show Common
Control Tasks.
2. On the Common DropDownList Tasks menu, click an existing data source or <New
Data Source...> in the Choose Data Source dropdown.
3. If you choose <New Data Source...>, configure a new data source in the Data Source
Configuration Wizard.
You can specify the layout, color, font, and alignment of the GridView control's rows. You can
specify the display of text and data contained in the rows. Additionally, you can specify whether
the data rows are displayed as items, alternating items, selected items, or edit-mode items. The
GridView control also allows you to specify the format of the columns.
To specify GridView control display options
1. Click the GridView control in Design view to select it, right-click the control, and
choose Properties from the shortcut menu to open theTag Properties task pane.
2. Specify the styles you want for the various GridView elements in the Styles category of
the Properties task pane. For example, under the Font property group in
the RowStyle property group, set the Name property to the font you want for the items in
the rows in the GridView.
EDITING AND DELETING DATA USING THE GRIDVIEW CONTROL
By default, the GridView control displays data in read-only mode. However, the control also
supports an edit mode in which it displays a row that contains editable controls such as TextBox
or CheckBoxcontrols. You can also configure the GridView control to display a Delete button
that users can click to delete the corresponding record from the data source.
The GridView control can automatically perform editing and deleting operations with its
associated data source, which allows you to enable editing behavior without writing code.
Alternatively, you can control the process of editing and deleting data programmatically, such as
in cases where the GridView control is bound to a read-only data source control.
To specify GridView control data editing options
1. In Design view, right-click the GridView control, and then click Show Common
Control Tasks.
2. Check the functionality you want:
 Enable paging — Displays only a subset of the records on a page and allows
a user to move from page to page to display more records. Enable sorting —
Allows a user to sort the records from the database. The GridView control
supports sorting by a single column without requiring any programming. You
can further customize the sort functionality of the GridView control by using
the sort event and providing a sort expression.
 Enable editing — Allows a user to make changes to the records.
 Enable deleting — Allows a user to delete rows from the database.
 Enable selection — Allows a user to select rows. You specify the look of
selected rows by setting the styles in theSelectedRowStyle group in
the Properties task pane.
DATABINDING WITH DATAGRIDVIEW IN ADO.NET
DataGridView is very powerful and flexible control for displaying records in a tabular (row-
column) form. Here I am describing a different way of databinding with a DataGridView control.
Take a windows Form Application -> take a DataGridView control.
Follow the given steps.
Step 1 : Select DataGridView control and click at smart property. Look at the following figure.
Step 2 : After clicking, a pop-up window will be open.
Step 3 : Click ComboBox
Step 4 : Click at Add Project Data Source (Look at above figure). A new window will be opened
to choose Data Source Type.
Step 5 : Choose Database (By default it is selected) and click the next button. A new window
will be open to Database Model.
Step 6 : Select DataSet (By default it is selected) and click the next button. A new window will
be open.
Step 7 : Click at New Connection button.
Step 8 : Write Server name, User name and Password of your SQL server and select Database
name. Look at the following figure.
Step 9 : Click "ok" button. After clicking ok button, you will reach the Data Source
Configuration Wizard.
Step 10 : Click the next button
Step 11 : Click on Table to explore all tables of your Database.
Step 12 : Click on the selected Database table to explore all columns
Step 13 : Check the CheckBox to select columns
Step 14 : Click the Finish button. You will note that the DataGridView will show all columns of
the table (Here, "Student_detail").
Run the application.
Output
Now we bind the DataGridView with database by code. Take another DataGridView control and
write the following code on the form load event.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace DatabindingWithdataGridView
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SqlDataAdapter dadapter;
DataSet dset;
string connstring = "server=.;database=student;user=sa;password=wintellect";
private void Form1_Load(object sender, EventArgs e)
{
dadapter = new SqlDataAdapter("select * from student_detail", connstring);
dset = new System.Data.DataSet();
dadapter.Fill(dset);
dataGridView1.DataSource = dset.Tables[0].DefaultView;
} } }
Ad

More Related Content

What's hot (20)

Python Flow Control
Python Flow ControlPython Flow Control
Python Flow Control
Mohammed Sikander
 
Event handling
Event handlingEvent handling
Event handling
swapnac12
 
Data Storage In Android
Data Storage In Android Data Storage In Android
Data Storage In Android
Aakash Ugale
 
Cookie & Session In ASP.NET
Cookie & Session In ASP.NETCookie & Session In ASP.NET
Cookie & Session In ASP.NET
ShingalaKrupa
 
C# Exceptions Handling
C# Exceptions Handling C# Exceptions Handling
C# Exceptions Handling
sharqiyem
 
The msg box function and the messagebox class
The msg box function and the messagebox classThe msg box function and the messagebox class
The msg box function and the messagebox class
Faisal Aziz
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
Pooja Jaiswal
 
Database management system Lecture 7 : Strong and weak entity sets
Database management system Lecture 7 : Strong and weak entity setsDatabase management system Lecture 7 : Strong and weak entity sets
Database management system Lecture 7 : Strong and weak entity sets
BIT Durg
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
anatomy of a jsp page & jsp syntax.pptx
anatomy of a jsp page & jsp syntax.pptxanatomy of a jsp page & jsp syntax.pptx
anatomy of a jsp page & jsp syntax.pptx
Sameenafathima4
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
RahulAnanda1
 
Chapter2 Encapsulation (Java)
Chapter2 Encapsulation (Java)Chapter2 Encapsulation (Java)
Chapter2 Encapsulation (Java)
Dyah Fajar Nur Rohmah
 
STRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIESSTRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIES
VENNILAV6
 
UNIT-1 PPT.pptCS 3492 DBMS UNIT 1 to 5 overview Unit 1 slides including purpo...
UNIT-1 PPT.pptCS 3492 DBMS UNIT 1 to 5 overview Unit 1 slides including purpo...UNIT-1 PPT.pptCS 3492 DBMS UNIT 1 to 5 overview Unit 1 slides including purpo...
UNIT-1 PPT.pptCS 3492 DBMS UNIT 1 to 5 overview Unit 1 slides including purpo...
SakkaravarthiS1
 
Introduction to ADO.NET
Introduction to ADO.NETIntroduction to ADO.NET
Introduction to ADO.NET
rchakra
 
Relational model
Relational modelRelational model
Relational model
Dabbal Singh Mahara
 
Database in Android
Database in AndroidDatabase in Android
Database in Android
MaryadelMar85
 
Packages in java
Packages in javaPackages in java
Packages in java
Elizabeth alexander
 
Delegates and events in C#
Delegates and events in C#Delegates and events in C#
Delegates and events in C#
Dr.Neeraj Kumar Pandey
 
Dbms 3: 3 Schema Architecture
Dbms 3: 3 Schema ArchitectureDbms 3: 3 Schema Architecture
Dbms 3: 3 Schema Architecture
Amiya9439793168
 
Event handling
Event handlingEvent handling
Event handling
swapnac12
 
Data Storage In Android
Data Storage In Android Data Storage In Android
Data Storage In Android
Aakash Ugale
 
Cookie & Session In ASP.NET
Cookie & Session In ASP.NETCookie & Session In ASP.NET
Cookie & Session In ASP.NET
ShingalaKrupa
 
C# Exceptions Handling
C# Exceptions Handling C# Exceptions Handling
C# Exceptions Handling
sharqiyem
 
The msg box function and the messagebox class
The msg box function and the messagebox classThe msg box function and the messagebox class
The msg box function and the messagebox class
Faisal Aziz
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
Pooja Jaiswal
 
Database management system Lecture 7 : Strong and weak entity sets
Database management system Lecture 7 : Strong and weak entity setsDatabase management system Lecture 7 : Strong and weak entity sets
Database management system Lecture 7 : Strong and weak entity sets
BIT Durg
 
anatomy of a jsp page & jsp syntax.pptx
anatomy of a jsp page & jsp syntax.pptxanatomy of a jsp page & jsp syntax.pptx
anatomy of a jsp page & jsp syntax.pptx
Sameenafathima4
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
RahulAnanda1
 
STRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIESSTRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIES
VENNILAV6
 
UNIT-1 PPT.pptCS 3492 DBMS UNIT 1 to 5 overview Unit 1 slides including purpo...
UNIT-1 PPT.pptCS 3492 DBMS UNIT 1 to 5 overview Unit 1 slides including purpo...UNIT-1 PPT.pptCS 3492 DBMS UNIT 1 to 5 overview Unit 1 slides including purpo...
UNIT-1 PPT.pptCS 3492 DBMS UNIT 1 to 5 overview Unit 1 slides including purpo...
SakkaravarthiS1
 
Introduction to ADO.NET
Introduction to ADO.NETIntroduction to ADO.NET
Introduction to ADO.NET
rchakra
 
Dbms 3: 3 Schema Architecture
Dbms 3: 3 Schema ArchitectureDbms 3: 3 Schema Architecture
Dbms 3: 3 Schema Architecture
Amiya9439793168
 

Similar to Grid view control (20)

Grid Vew Control VB
Grid Vew Control VBGrid Vew Control VB
Grid Vew Control VB
sunmitraeducation
 
Chapter12 (1)
Chapter12 (1)Chapter12 (1)
Chapter12 (1)
Rajalaxmi Pattanaik
 
GRID VIEW PPT
GRID VIEW PPTGRID VIEW PPT
GRID VIEW PPT
bon secours college for women,
 
Chapter 16
Chapter 16Chapter 16
Chapter 16
application developer
 
Grid View Control CS
Grid View Control CSGrid View Control CS
Grid View Control CS
sunmitraeducation
 
data binding.docx
data binding.docxdata binding.docx
data binding.docx
kishorebabu123
 
Database Connection
Database ConnectionDatabase Connection
Database Connection
John Joseph San Juan
 
Creating a dot netnuke
Creating a dot netnukeCreating a dot netnuke
Creating a dot netnuke
Nguyễn Anh
 
IntoTheNebulaArticle.pdf
IntoTheNebulaArticle.pdfIntoTheNebulaArticle.pdf
IntoTheNebulaArticle.pdf
David Harrison
 
IntoTheNebulaArticle.pdf
IntoTheNebulaArticle.pdfIntoTheNebulaArticle.pdf
IntoTheNebulaArticle.pdf
David Harrison
 
Cis407 a ilab 3 web application development devry university
Cis407 a ilab 3 web application development devry universityCis407 a ilab 3 web application development devry university
Cis407 a ilab 3 web application development devry university
lhkslkdh89009
 
Visual basic programming
Visual basic programmingVisual basic programming
Visual basic programming
SoundaryaB2
 
Visual basic programming
Visual basic programmingVisual basic programming
Visual basic programming
sowndaryadharmaraj
 
Mca 504 dotnet_unit5
Mca 504 dotnet_unit5Mca 504 dotnet_unit5
Mca 504 dotnet_unit5
Rai Saheb Bhanwar Singh College Nasrullaganj
 
Create a basic performance point dashboard epc
Create a basic performance point dashboard   epcCreate a basic performance point dashboard   epc
Create a basic performance point dashboard epc
EPC Group
 
Power BI Training Guide by workforce Dev
Power BI Training Guide by workforce DevPower BI Training Guide by workforce Dev
Power BI Training Guide by workforce Dev
Mariabernadettemanza
 
Business Intelligence Technology Presentation
Business Intelligence Technology PresentationBusiness Intelligence Technology Presentation
Business Intelligence Technology Presentation
John Paredes
 
OBIEE publisher with Report creation - Tutorial
OBIEE publisher with Report creation - TutorialOBIEE publisher with Report creation - Tutorial
OBIEE publisher with Report creation - Tutorial
onlinetrainingplacements
 
PowerBI Training
PowerBI Training PowerBI Training
PowerBI Training
Knowledge And Skill Forum
 
knowledgeforumpowerbitrainingnew-230816140827-5eb14be7.pdf
knowledgeforumpowerbitrainingnew-230816140827-5eb14be7.pdfknowledgeforumpowerbitrainingnew-230816140827-5eb14be7.pdf
knowledgeforumpowerbitrainingnew-230816140827-5eb14be7.pdf
Rame28
 
Creating a dot netnuke
Creating a dot netnukeCreating a dot netnuke
Creating a dot netnuke
Nguyễn Anh
 
IntoTheNebulaArticle.pdf
IntoTheNebulaArticle.pdfIntoTheNebulaArticle.pdf
IntoTheNebulaArticle.pdf
David Harrison
 
IntoTheNebulaArticle.pdf
IntoTheNebulaArticle.pdfIntoTheNebulaArticle.pdf
IntoTheNebulaArticle.pdf
David Harrison
 
Cis407 a ilab 3 web application development devry university
Cis407 a ilab 3 web application development devry universityCis407 a ilab 3 web application development devry university
Cis407 a ilab 3 web application development devry university
lhkslkdh89009
 
Visual basic programming
Visual basic programmingVisual basic programming
Visual basic programming
SoundaryaB2
 
Create a basic performance point dashboard epc
Create a basic performance point dashboard   epcCreate a basic performance point dashboard   epc
Create a basic performance point dashboard epc
EPC Group
 
Power BI Training Guide by workforce Dev
Power BI Training Guide by workforce DevPower BI Training Guide by workforce Dev
Power BI Training Guide by workforce Dev
Mariabernadettemanza
 
Business Intelligence Technology Presentation
Business Intelligence Technology PresentationBusiness Intelligence Technology Presentation
Business Intelligence Technology Presentation
John Paredes
 
OBIEE publisher with Report creation - Tutorial
OBIEE publisher with Report creation - TutorialOBIEE publisher with Report creation - Tutorial
OBIEE publisher with Report creation - Tutorial
onlinetrainingplacements
 
knowledgeforumpowerbitrainingnew-230816140827-5eb14be7.pdf
knowledgeforumpowerbitrainingnew-230816140827-5eb14be7.pdfknowledgeforumpowerbitrainingnew-230816140827-5eb14be7.pdf
knowledgeforumpowerbitrainingnew-230816140827-5eb14be7.pdf
Rame28
 
Ad

More from Paneliya Prince (20)

140120107044 ins ala.ppt
140120107044 ins ala.ppt140120107044 ins ala.ppt
140120107044 ins ala.ppt
Paneliya Prince
 
To create a web service
To create a web serviceTo create a web service
To create a web service
Paneliya Prince
 
Session and state management
Session and state managementSession and state management
Session and state management
Paneliya Prince
 
Master pages
Master pagesMaster pages
Master pages
Paneliya Prince
 
Master page
Master pageMaster page
Master page
Paneliya Prince
 
Managing states
Managing statesManaging states
Managing states
Paneliya Prince
 
Introduction to ado.net
Introduction to ado.netIntroduction to ado.net
Introduction to ado.net
Paneliya Prince
 
Asp.net validation
Asp.net validationAsp.net validation
Asp.net validation
Paneliya Prince
 
Asp.net control
Asp.net controlAsp.net control
Asp.net control
Paneliya Prince
 
Wt oep visiting card
Wt oep visiting cardWt oep visiting card
Wt oep visiting card
Paneliya Prince
 
SE OEP online car service booking
SE OEP online car service bookingSE OEP online car service booking
SE OEP online car service booking
Paneliya Prince
 
creating jdbc connection
creating jdbc connectioncreating jdbc connection
creating jdbc connection
Paneliya Prince
 
processing control input
processing control inputprocessing control input
processing control input
Paneliya Prince
 
static dictionary technique
static dictionary techniquestatic dictionary technique
static dictionary technique
Paneliya Prince
 
Ajava oep
Ajava oep Ajava oep
Ajava oep
Paneliya Prince
 
Ajava oep shopping application
Ajava oep shopping applicationAjava oep shopping application
Ajava oep shopping application
Paneliya Prince
 
creating jdbc connection
creating jdbc connectioncreating jdbc connection
creating jdbc connection
Paneliya Prince
 
DCDR
DCDRDCDR
DCDR
Paneliya Prince
 
static dictionary
static dictionarystatic dictionary
static dictionary
Paneliya Prince
 
ADO.net control
ADO.net controlADO.net control
ADO.net control
Paneliya Prince
 
Ad

Recently uploaded (20)

Compiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptxCompiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptx
RushaliDeshmukh2
 
Metal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistryMetal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistry
mee23nu
 
Avnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights FlyerAvnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights Flyer
WillDavies22
 
new ppt artificial intelligence historyyy
new ppt artificial intelligence historyyynew ppt artificial intelligence historyyy
new ppt artificial intelligence historyyy
PianoPianist
 
Introduction to FLUID MECHANICS & KINEMATICS
Introduction to FLUID MECHANICS &  KINEMATICSIntroduction to FLUID MECHANICS &  KINEMATICS
Introduction to FLUID MECHANICS & KINEMATICS
narayanaswamygdas
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 
Oil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdfOil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdf
M7md3li2
 
Compiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptxCompiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptx
RushaliDeshmukh2
 
Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptxData Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Journal of Soft Computing in Civil Engineering
 
15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...
IJCSES Journal
 
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
charlesdick1345
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
π0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalizationπ0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalization
NABLAS株式会社
 
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design ThinkingDT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DhruvChotaliya2
 
introduction to machine learining for beginers
introduction to machine learining for beginersintroduction to machine learining for beginers
introduction to machine learining for beginers
JoydebSheet
 
Degree_of_Automation.pdf for Instrumentation and industrial specialist
Degree_of_Automation.pdf for  Instrumentation  and industrial specialistDegree_of_Automation.pdf for  Instrumentation  and industrial specialist
Degree_of_Automation.pdf for Instrumentation and industrial specialist
shreyabhosale19
 
Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 
International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)
samueljackson3773
 
Compiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptxCompiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptx
RushaliDeshmukh2
 
Metal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistryMetal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistry
mee23nu
 
Avnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights FlyerAvnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights Flyer
WillDavies22
 
new ppt artificial intelligence historyyy
new ppt artificial intelligence historyyynew ppt artificial intelligence historyyy
new ppt artificial intelligence historyyy
PianoPianist
 
Introduction to FLUID MECHANICS & KINEMATICS
Introduction to FLUID MECHANICS &  KINEMATICSIntroduction to FLUID MECHANICS &  KINEMATICS
Introduction to FLUID MECHANICS & KINEMATICS
narayanaswamygdas
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 
Oil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdfOil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdf
M7md3li2
 
Compiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptxCompiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptx
RushaliDeshmukh2
 
Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptxData Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...
IJCSES Journal
 
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
charlesdick1345
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
π0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalizationπ0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalization
NABLAS株式会社
 
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design ThinkingDT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DhruvChotaliya2
 
introduction to machine learining for beginers
introduction to machine learining for beginersintroduction to machine learining for beginers
introduction to machine learining for beginers
JoydebSheet
 
Degree_of_Automation.pdf for Instrumentation and industrial specialist
Degree_of_Automation.pdf for  Instrumentation  and industrial specialistDegree_of_Automation.pdf for  Instrumentation  and industrial specialist
Degree_of_Automation.pdf for Instrumentation and industrial specialist
shreyabhosale19
 
Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 
International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)
samueljackson3773
 

Grid view control

  • 1. GridView control A recurring task in software development is to display tabular data. ASP.NET provides a number of tools for showing tabular data in a grid, including the GridView control. With the GridView control, you can display, edit, and delete data from many different kinds of data sources, including databases, XML files, and business objects that expose data. To add a GridView control to a page  Drag the GridView control from the Toolbox task pane to your page. After you add a GridView control, you can specify a data source for the control. To bind the GridView control to a data source 1. In Design view, right-click the GridView control, and then click Show Common Control Tasks. 2. On the Common DropDownList Tasks menu, click an existing data source or <New Data Source...> in the Choose Data Source dropdown. 3. If you choose <New Data Source...>, configure a new data source in the Data Source Configuration Wizard. You can specify the layout, color, font, and alignment of the GridView control's rows. You can specify the display of text and data contained in the rows. Additionally, you can specify whether the data rows are displayed as items, alternating items, selected items, or edit-mode items. The GridView control also allows you to specify the format of the columns. To specify GridView control display options 1. Click the GridView control in Design view to select it, right-click the control, and choose Properties from the shortcut menu to open theTag Properties task pane. 2. Specify the styles you want for the various GridView elements in the Styles category of the Properties task pane. For example, under the Font property group in the RowStyle property group, set the Name property to the font you want for the items in the rows in the GridView. EDITING AND DELETING DATA USING THE GRIDVIEW CONTROL By default, the GridView control displays data in read-only mode. However, the control also supports an edit mode in which it displays a row that contains editable controls such as TextBox
  • 2. or CheckBoxcontrols. You can also configure the GridView control to display a Delete button that users can click to delete the corresponding record from the data source. The GridView control can automatically perform editing and deleting operations with its associated data source, which allows you to enable editing behavior without writing code. Alternatively, you can control the process of editing and deleting data programmatically, such as in cases where the GridView control is bound to a read-only data source control. To specify GridView control data editing options 1. In Design view, right-click the GridView control, and then click Show Common Control Tasks. 2. Check the functionality you want:  Enable paging — Displays only a subset of the records on a page and allows a user to move from page to page to display more records. Enable sorting — Allows a user to sort the records from the database. The GridView control supports sorting by a single column without requiring any programming. You can further customize the sort functionality of the GridView control by using the sort event and providing a sort expression.  Enable editing — Allows a user to make changes to the records.  Enable deleting — Allows a user to delete rows from the database.  Enable selection — Allows a user to select rows. You specify the look of selected rows by setting the styles in theSelectedRowStyle group in the Properties task pane. DATABINDING WITH DATAGRIDVIEW IN ADO.NET DataGridView is very powerful and flexible control for displaying records in a tabular (row- column) form. Here I am describing a different way of databinding with a DataGridView control. Take a windows Form Application -> take a DataGridView control.
  • 3. Follow the given steps. Step 1 : Select DataGridView control and click at smart property. Look at the following figure.
  • 4. Step 2 : After clicking, a pop-up window will be open. Step 3 : Click ComboBox Step 4 : Click at Add Project Data Source (Look at above figure). A new window will be opened to choose Data Source Type.
  • 5. Step 5 : Choose Database (By default it is selected) and click the next button. A new window will be open to Database Model.
  • 6. Step 6 : Select DataSet (By default it is selected) and click the next button. A new window will be open. Step 7 : Click at New Connection button.
  • 7. Step 8 : Write Server name, User name and Password of your SQL server and select Database name. Look at the following figure. Step 9 : Click "ok" button. After clicking ok button, you will reach the Data Source Configuration Wizard.
  • 8. Step 10 : Click the next button Step 11 : Click on Table to explore all tables of your Database. Step 12 : Click on the selected Database table to explore all columns
  • 9. Step 13 : Check the CheckBox to select columns Step 14 : Click the Finish button. You will note that the DataGridView will show all columns of the table (Here, "Student_detail").
  • 10. Run the application. Output Now we bind the DataGridView with database by code. Take another DataGridView control and write the following code on the form load event.
  • 11. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; namespace DatabindingWithdataGridView { public partial class Form1 : Form { public Form1() { InitializeComponent(); } SqlDataAdapter dadapter; DataSet dset; string connstring = "server=.;database=student;user=sa;password=wintellect"; private void Form1_Load(object sender, EventArgs e) { dadapter = new SqlDataAdapter("select * from student_detail", connstring); dset = new System.Data.DataSet(); dadapter.Fill(dset); dataGridView1.DataSource = dset.Tables[0].DefaultView; } } }