Selecting a row in datagrid

Discussion in 'ASP .Net Datagrid Control' started by MB, May 24, 2004.

  1. MB

    MB Guest

    Hi,
    I want to use Datagrid with a button or any other way so that I can
    select one row that is required. Actually the database is searched for
    a particular value and results are displayed in the datagrid. Now what
    I want to do is select the required record (whole row) and the values
    of the row are then passed and saved in the db. It is form on which I
    search a paritcular record from the database and then select that
    record and then pass its values. Is there any way I can achieve this.
    Right now I have done this much. Now I dont know how to do it


    cn.Open()

    Dim prod As String
    prod = txtProdName.Text


    Dim selprod As String = String.Format("SELECT ProductID,
    ProductName FROM Products WHERE ProductName LIKE '%{0}%'", prod)

    'creating sql command object
    Dim conprod As SqlCommand
    conprod = New SqlCommand(selprod, cn)

    'creating data reader
    Dim dsprod As SqlDataReader
    dsprod = conprod.ExecuteReader

    'binding to dat grid
    DGProduct.DataSource = dsprod
    DGProduct.DataBind()

    'close datareader
    dsprod.Close()

    cn.Close()
    MB, May 24, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stu
    Replies:
    1
    Views:
    510
    makthar
    Aug 1, 2003
  2. =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=

    RE: Selecting a DataGrid row upon Page_Load

    =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=, May 14, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    413
    =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=
    May 14, 2004
  3. Scott Mitchell [MVP]

    Re: Selecting a DataGrid row upon Page_Load

    Scott Mitchell [MVP], May 14, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    423
    Scott Mitchell [MVP]
    May 14, 2004
  4. Chip

    Selecting a row within a row

    Chip, Feb 10, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    362
  5. misiek
    Replies:
    0
    Views:
    2,281
    misiek
    Feb 20, 2006
Loading...

Share This Page