views:

206

answers:

1

I have a fairly simple form:

<asp:FormView>
    <EditItemTemplate>
        <asp:LoginView>
            <RoleGroups>
                <asp:RoleGroup roles="Blah">
                    <ContentTemplate>
                        <!-- Databound Controls using Bind/Eval -->
                    </ContentTemplate>
                </asp:RoleGroup>
            </RoleGroups>
        </asp:LoginView>

        <!-- Databound Controls -->
    </EditItemTemplate>
</asp:FormView>

<asp:LinqDataSource OnUpdating="MyDataSource_Updating" />

I handle my LinqDataSource OnUpdating event and do some work handling some M:N fields. That all works.

However, once the update is finished (and I call e.Cancel = true), the LoginView control does not databind its children... so they are all blank. The FormView's viewstate is still fine, as all the rest of the controls outside of the LoginView appear fine. I even handle the FormView_DataBound event and a Trace shows that the FormView is being databound on postback.

Why then is the LoginView not keeping its ViewState/being databound? Here's a sample code snippet showing the flow:

protected void MyDataSource_Updating(object s, LinqDataSourceUpdateEventArgs e)
{
    try 
    {
        Controller.DoSomething(newData);
        // attempts to databind again here fail
        // frmView.DataBind();
        // MyDataSource.DataBind();
        // LoginView.DataBind();
    }
    catch { // blah }
    finally 
    { 
        e.Cancel = true; 
    }
}
A: 

I fixed this by reverting to the age old method of databinding everything myself and axing the LoginView.

subkamran