Results 1 to 3 of 3

Thread: Getting data from a selected row in gridview in VB.Net

  1. #1
    Join Date
    Dec 2008
    Posts
    7

    Getting data from a selected row in gridview in VB.Net

    Hi,

    I have a gridview which is being populated with no problems.
    I want to be able to reference the data from the cells in the row
    Can anyone provide me with the code that will allow me to access the
    data in each cell.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: Getting data from a selected row in gridview in Asp.Net

    // Copy the items in the Rows collection into an array.

    GridViewRow[] rowArray = new GridViewRow[gv.Rows.Count];
    gv.Rows.CopyTo(rowArray, 0);

    // Iterate though the array and display the value in the first cell of the row.

    int j = -1;
    foreach (GridViewRow row in rowArray)
    {
    j++;
    if (j == idx)
    {
    Label1.Text = row.Cells[1].Text;
    }
    }

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Getting data from a selected row in gridview in Asp.Net

    You can do it simply by using this given code.

    dim string1 as string

    string1 = gridview1.rows(row#).cells(cell#).text.tostring

Similar Threads

  1. Extracting Selected Data from a txt file
    By sidney786 in forum Software Development
    Replies: 3
    Last Post: 20-08-2010, 01:07 AM
  2. Retrieve selected Data From a Table
    By samualres in forum Software Development
    Replies: 5
    Last Post: 30-01-2010, 10:04 AM
  3. Datagrid VS Gridview
    By Techno Guru in forum Software Development
    Replies: 5
    Last Post: 16-01-2010, 12:42 PM
  4. Replies: 2
    Last Post: 08-06-2009, 09:54 PM
  5. asp.net gridview to pdf
    By Dietrich in forum Software Development
    Replies: 1
    Last Post: 05-02-2009, 12:15 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,164,006.40969 seconds with 16 queries