LoginView inside FormView control is not databinding on PostBack
Posted
by subkamran
on Stack Overflow
See other posts from Stack Overflow
or by subkamran
Published on 2010-04-20T03:26:31Z
Indexed on
2010/04/20
3:33 UTC
Read the original article
Hit count: 615
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;
}
}
© Stack Overflow or respective owner