Retrieve data from Datagrid???

  • Thread starter Thread starter crocketo
  • Start date Start date
C

crocketo

Hi,

I've made a winform with several labels, textboxes and a datagrid. My
question is:

How do I, when a row in the datagrid is clicked, retrieve that data? Let's
say I've got a datagrid with the columns NAME, AUTHOR and TYPE - So when I
click a row in the data grid I want the data from NAME, AUTHOR and TYPE to
appear in their respective textboxes. How do I do that?

/KF
 
Just to let you know I am grappling with the same problem in .net 2003.
If you get anywhere please let me know and I'll do the same..

Tim Heap
Software & Database Manager
POSTAR Ltd
www.postar.co.uk
(e-mail address removed)
 
Hi.

I finally made it work. I just implemented the following method. I had
written this code first, but wanted to try databinding on textboxes...I
couldn't get it to work. This works, thought :

private void dataGrid_Click(object sender, System.EventArgs e)

{

int row = dataGrid.CurrentRowIndex;

dataGrid.Select(row);

ArrayList arrayList = new ArrayList();

for(int i = 0; i<3; i++)

{

arrayList.Insert(i,(ds.Tables["songs"].Rows[row].ItemArray.GetValue(i)) );

}

remName_txt.Text = "" + arrayList[0];

remAuthor_txt.Text = "" + arrayList[1];

remType_txt.Text = "" + arrayList[2];

}



/KF
 
Back
Top