Hi Andrew,
Welcome to ASPNET newsgroup.
As for the template databound controls such as GridView/DetailsView, and
the original DataGrid and DAtaList ...., the DataSource instance (DataSet,
DataTable ...) only exist when the datacontrol is performing databinding.
After that, the datasource instance no longer exist in the sequential
request, the datas are persisted in the control through ViewState. So we
can not directly obtain the original DataSet/DataTable back from The
databound control on the page. If you're wantting to retrieve the updated
values (of the controls) in each row and do manual data updating, we have
the following options:
1. We still use the DetailsView control's buildin updating mechanism, but
use the ItemUpdating event to proprocess the update operation. The
ItemUpdating event, we can get the paramters that will be used to do the
updating operation and then use them to perform our own update operation.
And we can use the
DetailsViewUpdateEventArgs.Cancel to cancel the buildin update operation.
2. If we don't want the utilize the buildin events, we can use the
DetailsView.Rows and DetailsViewRow.Cells collection to manually retrieve
the values from the Bounded control's Text Property. Like:
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write("<br>DetailsView1.Rows.Count: " + DetailsView1.Rows.Count);
foreach (DetailsViewRow dvr in DetailsView1.Rows)
{
Response.Write("<br>dvr.Cells.Count: " + dvr.Cells[1].Text);
}
}
However, all the above options can only retrieve the values for the
currently active (displayed ) record. Unlike the DataGrid, GridView,
DetailsView dosn't provide the direct interfaces for loop through all the
records's data.
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.)
--------------------
microsoft.public.dotnet.framework.aspnet:128339
with a
|