For the most part no. A data reader is by definition a read-only, forward
view of the DB contents. You can't change the values it returns. However
you can enumerate the results of the data reader and build a new data source
(such as an array of custom objects) that you could then filter and bind to
the DataGrid.
Most people just find it easier to use a DataSet when supporting editable
DataGrids. That is the textbook answer to your common problem. That is one
of the reasons why DataSets were created to begin with. I'd recommend that
approach. You can then filter and sort your results as needed prior to
sending to the DataGrid.
FYI, there are 2 DataGrids; one in ASP.NET and one in WinForms. They are
quite different. In future posts specify which one you are talking about.
You should also post such questions in the WindowsForms or ASP.NET newsgroups
instead of this language specific group. The control works the same
irrelevant of the underlying language. In this group you will only get
answers from C# people.
Hope this helps,
Michael Taylor, MCP, MCAD - 6/29/05
"Wing" wrote:
Hi all,
I execute a stored procedure in my C# code, assign the result to the
SqlDataReader object and display it with datagrid.
the question I like to ask, is possible to edit the datagrid output
(eg. delete a row in the datagrid) and update the change in the
corresponding table in the database?
thanks for your time.
Wing