Quantcast
Channel: Learn C# » c# .net grid control
Viewing all articles
Browse latest Browse all 2

How to use DataGrid in C# .Net?

$
0
0

First place the DataGridView Control in the form.In the coding add the namespasce

using System.Data.SqlClient;

then initialize SqlConnection to ConnString as public (i.e)next to public Form1( ) {InitializeComponent( );}

SqlConnection con = new SqlConnection(“Your Connection String”);

DataSet ds;

Inside any event such as Form_load or button1_click add the code

SqlDataAdapter da=new SqlDataAdapter(“select * from table1″,con);

ds=new DataSet();

da.Fill(ds,”table1″);

dataGridView1.DataSource=ds;

dataGridView1.DataMember=”table1″;

By

Udhaya



Viewing all articles
Browse latest Browse all 2

Trending Articles