Selecting a row in datagrid

M

MB

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()
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top