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