B
berto
hi all,
I am working in ASP.NET & SQLServer and:
my problem is that I have a DataGrid wich is created sometimes with a
whole SQLServer table, and other times with only some rows of it (I
make a search in the same page).
The problem is that I have an edit column in the DataGrid, but if I
make a search and for example 2 rows are returned, if I click (for
example) on the second row to edit it, the DataGrid returns to the
listing of all the rows of the table and the row wich is editable is
not the one I clicked it's (in that case) the second row of the table.
Is there any way I can do that?
Here's the code I use to search and the one I use to bind the datagrid.
I hope someone can help me. Thanks in advance
CODE:
// sub for searching
Sub CercarClick(Source As Object, e As EventArgs)
Dim DS As DataSet
Dim MyDA As SqlDataAdapter
Dim MyCmd As SqlCommand
if name.value<>"" then
// name is the search field
MyDA = New SqlDataAdapter()
MyCmd = new SqlCommand("limp_CercaUsers", MyConnection)
MyCmd.Parameters.Add("@UserName", SqlDbType.VarChar, 10)
MyCmd.Parameters("@UserName").Value = name.value
MyCmd.CommandType = CommandType.StoredProcedure
MyDA.SelectCommand = MyCmd
DS = new DataSet()
MyDA.Fill(DS, "limp_usuarisLyser")
MyDataGrid.DataSource = DS.Tables("limp_usuarisLyser").DefaultView
MyDataGrid.DataBind()
else
Message.Text = "ERROR"
end if
End sub
// code I use to Bind the Data
Sub BindGrid()
Dim DS As DataSet
Dim MyCommand As SqlDataAdapter
MyCommand = new SqlDataAdapter("select * from limp_usuarisLyser",
MyConnection)
DS = new DataSet()
MyCommand.Fill(DS, "limp_usuarisLyser")
MyDataGrid.DataSource=DS.Tables("limp_usuarisLyser").DefaultView
MyDataGrid.DataBind()
End Sub
I am working in ASP.NET & SQLServer and:
my problem is that I have a DataGrid wich is created sometimes with a
whole SQLServer table, and other times with only some rows of it (I
make a search in the same page).
The problem is that I have an edit column in the DataGrid, but if I
make a search and for example 2 rows are returned, if I click (for
example) on the second row to edit it, the DataGrid returns to the
listing of all the rows of the table and the row wich is editable is
not the one I clicked it's (in that case) the second row of the table.
Is there any way I can do that?
Here's the code I use to search and the one I use to bind the datagrid.
I hope someone can help me. Thanks in advance
CODE:
// sub for searching
Sub CercarClick(Source As Object, e As EventArgs)
Dim DS As DataSet
Dim MyDA As SqlDataAdapter
Dim MyCmd As SqlCommand
if name.value<>"" then
// name is the search field
MyDA = New SqlDataAdapter()
MyCmd = new SqlCommand("limp_CercaUsers", MyConnection)
MyCmd.Parameters.Add("@UserName", SqlDbType.VarChar, 10)
MyCmd.Parameters("@UserName").Value = name.value
MyCmd.CommandType = CommandType.StoredProcedure
MyDA.SelectCommand = MyCmd
DS = new DataSet()
MyDA.Fill(DS, "limp_usuarisLyser")
MyDataGrid.DataSource = DS.Tables("limp_usuarisLyser").DefaultView
MyDataGrid.DataBind()
else
Message.Text = "ERROR"
end if
End sub
// code I use to Bind the Data
Sub BindGrid()
Dim DS As DataSet
Dim MyCommand As SqlDataAdapter
MyCommand = new SqlDataAdapter("select * from limp_usuarisLyser",
MyConnection)
DS = new DataSet()
MyCommand.Fill(DS, "limp_usuarisLyser")
MyDataGrid.DataSource=DS.Tables("limp_usuarisLyser").DefaultView
MyDataGrid.DataBind()
End Sub