How to modify SqlDataAdapter field prior to render in GridView?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an encoded field in my database which needs to be modified to
something readable prior to its rendering in GridView or DetailsView contol.
How do I access the underlying DataTable or the GridView field? I'd like to
do something like SqlDataAdapter.MyTable.MyRow.MyField = "Render This";
 
Hi,

Welcome to ADONET newsgroup.
Regarding on the problem you mentioned, based on my experience, we have two
options generally:
1. If we're going to do the interception at DataSource level, we may need
to manually use code to construct dataadapter (or sqlcommand) and modify
the returned dataset/datatable. Then, bind the modified dataset/table to
the databound controls.

2. We can also do the manipulation at databound control level(UI level).
For those template databound control, (such as DataGrid, DataList,
GridView), they all have certain events for intercept the binded data value
at runtime. For example, the GridView.RowDataBound event is used for
intercepting the GridView's DataBound processing at runtime. The passed
arguments in the event can help retrieve the currently row under binding
and the current binded data objects(just like the ItemDataBound event for
the asp.net 1.x 's DataGrid control):

#GridView.RowDataBound Event
http://msdn2.microsoft.com/library/y287zyfb(en-us,vs.80).aspx

IMO, I think the #2 option is much more prefered since doing such
formatting at UI/display layer is more reasonable.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



--------------------
| Thread-Topic: How to modify SqlDataAdapter field prior to render in
GridView?
| thread-index: AcWcUNn32cGSG20OQlmbKPmaxNs3DA==
| X-WBNR-Posting-Host: 192.85.47.2
| From: "=?Utf-8?B?UmFkaW9TaWduYWw=?=" <[email protected]>
| Subject: How to modify SqlDataAdapter field prior to render in GridView?
| Date: Mon, 8 Aug 2005 12:39:11 -0700
| Lines: 4
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.adonet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.framework.adonet:33675
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| I have an encoded field in my database which needs to be modified to
| something readable prior to its rendering in GridView or DetailsView
contol.
| How do I access the underlying DataTable or the GridView field? I'd like
to
| do something like SqlDataAdapter.MyTable.MyRow.MyField = "Render This";
|
 
Thanks, Steven. Method #2 worked real well for the GridView control. Is there
anyway to get that to work for a DetailsView control or am I stuck with
method #1?
 
Thanks for your response,

Well, for DetailsView, based on my research, it also has a certain event
named "ItemCreated" event, according to the current document, it is offen
used to modify the record before it being displayed:

http://msdn2.microsoft.com/library/7z482d0y(en-us,vs.80).aspx

In addition, for those template databound control( DataGrid, GridView,
DetailsView.....), we can also define template Column rather than the
simple boundColumn(boundField ) , since we can use manual databinding
expression in template column/field, it'll be much easier for us to do
cusomization.

Thanks & Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| Thread-Topic: How to modify SqlDataAdapter field prior to render in
GridView
| thread-index: AcWdPbh+grgU9egOS2KZjLz1xclEPg==
| X-WBNR-Posting-Host: 24.74.0.57
| From: "=?Utf-8?B?UmFkaW9TaWduYWw=?=" <[email protected]>
| References: <[email protected]>
<[email protected]>
| Subject: RE: How to modify SqlDataAdapter field prior to render in
GridView
| Date: Tue, 9 Aug 2005 16:54:46 -0700
| Lines: 76
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.adonet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.framework.adonet:33733
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| Thanks, Steven. Method #2 worked real well for the GridView control. Is
there
| anyway to get that to work for a DetailsView control or am I stuck with
| method #1?
|
| "Steven Cheng[MSFT]" wrote:
|
| > Hi,
| >
| > Welcome to ADONET newsgroup.
| > Regarding on the problem you mentioned, based on my experience, we have
two
| > options generally:
| > 1. If we're going to do the interception at DataSource level, we may
need
| > to manually use code to construct dataadapter (or sqlcommand) and
modify
| > the returned dataset/datatable. Then, bind the modified dataset/table
to
| > the databound controls.
| >
| > 2. We can also do the manipulation at databound control level(UI
level).
| > For those template databound control, (such as DataGrid, DataList,
| > GridView), they all have certain events for intercept the binded data
value
| > at runtime. For example, the GridView.RowDataBound event is used for
| > intercepting the GridView's DataBound processing at runtime. The passed
| > arguments in the event can help retrieve the currently row under
binding
| > and the current binded data objects(just like the ItemDataBound event
for
| > the asp.net 1.x 's DataGrid control):
| >
| > #GridView.RowDataBound Event
| > http://msdn2.microsoft.com/library/y287zyfb(en-us,vs.80).aspx
| >
| > IMO, I think the #2 option is much more prefered since doing such
| > formatting at UI/display layer is more reasonable.
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| >
| > --------------------
| > | Thread-Topic: How to modify SqlDataAdapter field prior to render in
| > GridView?
| > | thread-index: AcWcUNn32cGSG20OQlmbKPmaxNs3DA==
| > | X-WBNR-Posting-Host: 192.85.47.2
| > | From: "=?Utf-8?B?UmFkaW9TaWduYWw=?=" <[email protected]>
| > | Subject: How to modify SqlDataAdapter field prior to render in
GridView?
| > | Date: Mon, 8 Aug 2005 12:39:11 -0700
| > | Lines: 4
| > | Message-ID: <[email protected]>
| > | MIME-Version: 1.0
| > | Content-Type: text/plain;
| > | charset="Utf-8"
| > | Content-Transfer-Encoding: 7bit
| > | X-Newsreader: Microsoft CDO for Windows 2000
| > | Content-Class: urn:content-classes:message
| > | Importance: normal
| > | Priority: normal
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| > | Newsgroups: microsoft.public.dotnet.framework.adonet
| > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.adonet:33675
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
| > |
| > | I have an encoded field in my database which needs to be modified to
| > | something readable prior to its rendering in GridView or DetailsView
| > contol.
| > | How do I access the underlying DataTable or the GridView field? I'd
like
| > to
| > | do something like SqlDataAdapter.MyTable.MyRow.MyField = "Render
This";
| > |
| >
| >
|
 
Back
Top