Datagridview value
i have a list of values in datagridview. i want to show the selected row values from one datagridview into another datagridview....
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
ShankeyRank #972 · 2.1K reputationPosted Feb 13, 2011, 11:21 PM EST
http://social.msdn.microsoft.com/Forums/en/winforms/thread/9d9bf88e-ec2f-4e5d-ad44-a65de705fe16
http://weblogs.asp.net/hpreishuber/archive/2005/08/05/421712.aspx
Madhu KRank #1,514 · 1.1K reputationPosted Feb 14, 2011, 1:44 AM EST
This dirty code will give you an idea
//cell click event to
private void GridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
RowId = GridView1.CurrentRow.Index;
DataTable dt = new DataTable();
DataColumn dc = new DataColumn("id");
DataColumn dc1 = new DataColumn("name");
DataRow dr = dt.NewRow();
dt.Columns.Add(dc); dt.Columns.Add(dc1);
dr["CSID"] = CSGridView1.Rows[RowId].Cells[0].Value;
dr1["Name"] = CSGridView1.Rows[RowId].Cells[1].Value; //
dt.Rows.Add(dr);
dataGridView1.DataSource = dt;
}
Amit ChoudharyRank #145 · 15.8K reputationPosted Feb 14, 2011, 2:06 AM EST
use int RowID= e.RowIndex;
instead of RowId = GridView1.CurrentRow.Index;
Rest code is good to go..
junaid sarfraz11 reputationPosted Feb 14, 2011, 2:11 AM EST
Suthish NairRank #92 · 22.8K reputationPosted Feb 15, 2011, 9:48 PM EST