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. Advertisements

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:
    601
    makthar
    Aug 1, 2003
  2. Chip

    Selecting a row within a row

    Chip, Feb 10, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    464
  3. misiek
    Replies:
    0
    Views:
    2,415
    misiek
    Feb 20, 2006
  4. rcoco

    selecting one row from datagrid

    rcoco, Jan 10, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    521
    Rastko Soskic
    Jan 11, 2007
  5. jcardenasch

    selecting a row in a datagrid problem

    jcardenasch, Aug 20, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    122
    jcardenasch
    Aug 20, 2003
  6. Liuc
    Replies:
    4
    Views:
    287
  7. Graeme

    selecting datagrid row

    Graeme, Aug 27, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    169
    Graeme
    Aug 27, 2004
  8. dew

    Automatically selecting a datagrid row

    dew, Mar 30, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    142
Loading...