Retrieve data from Datagrid???

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • crocketo

    Retrieve data from Datagrid???

    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


  • Tim Heap

    #2
    Re: Retrieve data from Datagrid???

    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

    tim@postar.co.u k

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!

    Comment

    • KF

      #3
      Re: Retrieve data from Datagrid???

      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.EventArg s e)

      {

      int row = dataGrid.Curren tRowIndex;

      dataGrid.Select (row);

      ArrayList arrayList = new ArrayList();

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

      {

      arrayList.Inser t(i,(ds.Tables["songs"].Rows[row].ItemArray.GetV alue(i)) );

      }

      remName_txt.Tex t = "" + arrayList[0];

      remAuthor_txt.T ext = "" + arrayList[1];

      remType_txt.Tex t = "" + arrayList[2];

      }



      /KF



      "Tim Heap" <tim@postar.co. uk> wrote in message
      news:ueikYwEpDH A.964@TK2MSFTNG P10.phx.gbl...[color=blue]
      > 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
      > tim@postar.co.u k
      >
      > *** Sent via Developersdex http://www.developersdex.com ***
      > Don't just participate in USENET...get rewarded for it![/color]


      Comment

      Working...