How to use Data Grid View Control?
pls send me with Example
Thanks&Regs
Magesh
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sam HobbsPosted Mar 17, 2012, 8:28 PM
Then, after reading some articles, when you need to request assistance in the C# Corner forums, you need to ask the questions in the Windows Forms forum or whatever UI you are using but not the C# Language forum.
Satyapriya NayakPosted Mar 17, 2012, 6:49 AM
To display data in a datagridview from database.
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.OleDb;
namespace Datagridview_bind
{
public partial class Form1 : Form
{
string ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["dsn"];
OleDbCommand com;
OleDbDataAdapter oda;
DataSet ds;
string str;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection(ConnectionString);
con.Open();
str = "select * from customer";
com = new OleDbCommand(str, con);
oda = new OleDbDataAdapter(com);
ds = new DataSet();
oda.Fill(ds, "customer");
dataGridView1.DataMember = "customer";
dataGridView1.DataSource = ds;
con.Close();
}
}
}
Thanks
SenthilkumarPosted Mar 17, 2012, 4:21 AM
The MSDN have some description about the GridView usage with an example.
http://msdn.microsoft.com/en-us/library/aa479342.aspx
You can find more examples like GridView Binding, edit, update, Loading images, dropdown, etc..,in the following examples.
http://www.dotnetspider.com/resources/Category518-ASP-NET-GridView.aspx
http://www.c-sharpcorner.com/uploadfile/raj1979/gridview-examples-for-Asp-Net-2-0/
http://www.exforsys.com/tutorials/asp.net-2.0/asp.net-2.0-the-gridview-control.html