Edit the contents of a loaded SQL DataReader?

J

Jack Black

Hi, all! I have a populated Reader that I'm binding to a data grid,
and I'm trying to figure out how I can edit cells BEFORE binding the
reader to the DataGrid. Of the few pieces of sample code I've seen a
DataSet is required, and I really don't want to dump a lot of code
into something that may not need it: a quick bind to a reader dumps
data perfectly with zero hassle! ;-)

Obviously the Reader is (duh) read only, so I was wondering if there
was some other quick way to get where I want to go. Essentially, I
just want a simple text replacement on the contents of a field in the
recordset: for example, replace a "99" with "1999" (just an example,
not a date thing).

Thoughts?? Thanks in advance!
Jack
 
D

Davide Vernole [MVP]

Jack Black said:
Hi, all! I have a populated Reader that I'm binding to a data grid,
and I'm trying to figure out how I can edit cells BEFORE binding the
reader to the DataGrid. Of the few pieces of sample code I've seen a
DataSet is required, and I really don't want to dump a lot of code
into something that may not need it: a quick bind to a reader dumps
data perfectly with zero hassle! ;-)

Obviously the Reader is (duh) read only, so I was wondering if there
was some other quick way to get where I want to go. Essentially, I
just want a simple text replacement on the contents of a field in the
recordset: for example, replace a "99" with "1999" (just an example,
not a date thing).

Thoughts?? Thanks in advance!
Jack

As you know, DataReader is read-only forward only so you cannot change any
field or record. The solution is to work in the event around the bind to the
datagrid.

You could change this value in the ItemDataBound event of the DataGrid.
 

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
474,434
Messages
2,571,690
Members
48,796
Latest member
Greg L.

Latest Threads

Top