Hi,
I'm still hacking at this problem. I've approached it from several angles
and still get get this done.
To recap:
I'm using a wizard to provide navigation through multiple data entry pages.
Each page is a separate table in a sql database. Each entry screen is a
FormView that's built as an ascx, which is dropped into the wizardstep.
When the Complete page is reached, I've put a button to do the update. The
update button calls code in the App_Code folder. The update method takes the
Page as a parameter and recursively searches the wiz pages for sqlDataSources
with a certain prefix and creates a list which it returns to the caller. The
caller then passes the list of sqlDatasources to an update method which loops
through the SqlDataSources. For each SqlDataSource 2 additional fields are
populated into the DataSource's Parameters and then performs the Insert() on
the data source.
What's actually happening is that the Data tables (all 10 of them) ARE being
inserted BUT only the last 2 fields that I've insertd values for, are getting
written to the table, all the user inserted data is being left behind and
show up null in the database. I know that this is happening because one of
the values that I write into the table is an integer that's incremented each
time I run a test.
I've taken the approach that there needs to be a DataBind() executed. I
tried that on the SqlDataSource, on the parent ascx and on the FormView each
in different iterations of the code. Nothing seems to work. I've also put
an OnInserting call back and can see the data in the Ascx textbox fields as
the user entered it while the Insert is in progress.
It seems like the goal is to update the InsertParameters but it seems kind
of dorky to update those manually (though I'm considering it at this point
:-( ).
Here's an example of the insert code.
while( sSrces.MoveNext() )
{
SqlDataSource theSrce = (SqlDataSource)sSrces.Current;
foreach (Control ctrl in theSrce.Parent.Controls)
{
if (ctrl.GetType() == typeof(FormView))
{
ctrl.DataBind();
}
}
theSrce.InsertParameters["FK_Pat"].DefaultValue =
PK_Pat.ToString();
theSrce.InsertParameters["FK_MedRec"].DefaultValue =
medRecId.ToString();
// I've also tried theSrce.DataBind();
theSrce.Insert();
}
I've tried everything I can think of. Any ideas?
Thanks
--
TenDot
TenDot said:
I'm using a wizard to collect data that will go into multiple tables. each
Wizstep has a separate DataSource object. When the Complete wizstep is
reached I want to update all the datasources with a common value in a column.
That key will not be know till the user saves.
I've tried:
SqlDataSource theSrce = (SqlDataSource)sSrces.Current;
DataView dv =
(DataView)theSrce.Select(DataSourceSelectArguments.Empty);
dv[0].BeginEdit();
dv[0]["FK_MedRec"] = 1;//
(int)HttpContext.Current.Session["MedRecId"];
dv[0]["FK_Pat"] =
1;//(int)HttpContext.Current.Session["MedRecId"];
dv[0].EndEdit();
theSrce.Insert();
I get access to dv[0] but everytime I try to insert I get an error tellling
me that dv[0]["FK_Pat"] is null (which is a constraint).
Am I doing something wrong?
TIA