Hi Martin,
From your description, I understand you're using the ASP.NET 2.0
AccessDataSource control to query some data from a certain mdb data file
and display it on a GridView through DataBinding. However, you're
wondering how to access the underlying DataTable in memory(generated by the
AccessDataSource control) ,correct?
As for the AccessDataSource control(same as SqlDatasource control) , it
doesn't naturally expose a property or method that allow us to hook the
underlying DataTable it generated and asociate to databinding control(when
we use DataSourceID) to bind the data.
For your scenario, I'm wondering whether you just want to query the data
for display only or is it possible that we use programmatic databinding
here instead of DataSourceID? If this is possible, you can consider
manually call the AccessDataSource control's Select method to get the
underlying dataobject and bind it to GridView e.g:
===================
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataView dv =
AccessDataSource1.Select(DataSourceSelectArguments.Empty) as DataView;
GridView1.DataSource = dv;
GridView1.DataBind();
}
}
=====================
Thus, you can get the reference to the DataView object.
Another solution is to use ObjectDataSource instead of AccessDataSource,
and you can create a TableAdapter/DataSet pair for querying data from
Access mdb file. The VS 2005 IDE can help create typed TableAdapter and
DataSet conveniently through user interface, and you can either use the
TableAdapter programmtically or configure it in ObjectDataSource and use
it, here are some related msdn reference:
#TableAdapters in Visual Studio 2005
http://msdn.microsoft.com/library/en-us/dnvs05/html/tableadapters.asp?frame=
true
#ObjectDataSource
http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/data/objectdatas
ource.aspx
After you bind ObjectDataSource to GridView, you can use the
ObjectDataSource.Selected event to hook the underlying returned data
object. e.g
==============
protected void ObjectDataSource1_Selected(object sender,
ObjectDataSourceStatusEventArgs e)
{
Response.Write("<br/>" + e.ReturnValue.GetType());
}
===============
Please feel free to let me know if you have anything unclear or if there is
any else we can help.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.