.Net
sir i want the cell information of grid view when we click on any cell in grid view , we get all updated value for a particular cell
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.
Satyapriya NayakPosted Jul 11, 2012, 4:41 AM
Try
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_select_textbox_data
{
public partial class Form1 : Form
{
string ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["dsn"];
OleDbCommand com;
OleDbDataAdapter oledbda;
string str;
DataSet ds;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
bindgrid();
}
private void bindgrid()
{
OleDbConnection con = new OleDbConnection(ConnectionString);
con.Open();
str = "select * from employee";
com = new OleDbCommand(str, con);
oledbda = new OleDbDataAdapter(com);
ds = new DataSet();
oledbda.Fill(ds, "employee");
dataGridView1.DataMember = "employee";
dataGridView1.DataSource = ds;
con.Close();
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
txt_sno.Text = "";
bool FirstValue = true;
foreach (DataGridViewCell cell in dataGridView1.SelectedCells)
{
if (!FirstValue)
{
txt_sno.Text += ", ";
}
txt_sno.Text += cell.Value.ToString();
FirstValue = false;
}
}
}
}
Thanks