O
olduncleamos
Hello all,
I am experimenting with the repeater control and ran into something
that I wasn't expecting. I would appreciate if the experts can confirm
or correct my understanding.
Here is a fragment of a very simple page that I wrote that will drill
down into the displayed item. The result is to be display on the same
page so that the user can keep on drilling down:
<asp:Repeater id="rptCtrl1" runat="server" EnableViewState="true" >
<ItemTemplate>
<asp:LinkButton ID="lnkItem" Runat="server"
EnableViewState="true" CommandName="DrillDown"></asp:LinkButton>
<br>
</ItemTemplate>
</asp:Repeater>
The OnItemCommand event for the Repeater is connected to the
rptCtrl1_OnItemCommand function:
public void rptCtrl1_OnItemCommand(object source,
System.Web.UI.WebControls.RepeaterCommandEventArgs e)
{
LinkButton lnkButton = (LinkButton)e.CommandSource;
string param = lnkButton.CommandArgument.ToString();
makeDataBind(param);
}
The makeDataBind function will perform the data binding depends on the
link that was clicked. All is fine when the EnableViewState was set to
true for both the repeater and the link button.
When the EnableViewState of the Repeater control is set to false, the
OnItemCommand event doesn't fire;
When the EnableViewState of the Linkbutton is set to false, the
LinkButton is not found in the OnItemCommand event.
I understand that the ViewState is responsible for recreating the
controls on the page. Without the ViewState, the link button was not
recreated so I couldn't get the link button during the event.
But why didn't the Repeater's OnItemCommand event fire when the
ViewState was disabled? If it was a button, the OnClick event will
still fire if the ViewState for the control is set to false.
Is it because the link button won't be recreated if the Repeater's
ViewState was disabled? Without the link button, there was no event to
bubble up?
One other question: With the code above, I can drill down to level 1
from level 0. If I press the back button from level 1, I go back to
level 0. But if I press the back button from level 2, I get a page
cannot be displayed error. If I press the back button again, I go back
to level 0.
I look forward to any advise and suggestions. Thanks in advance.
-Amos
I am experimenting with the repeater control and ran into something
that I wasn't expecting. I would appreciate if the experts can confirm
or correct my understanding.
Here is a fragment of a very simple page that I wrote that will drill
down into the displayed item. The result is to be display on the same
page so that the user can keep on drilling down:
<asp:Repeater id="rptCtrl1" runat="server" EnableViewState="true" >
<ItemTemplate>
<asp:LinkButton ID="lnkItem" Runat="server"
EnableViewState="true" CommandName="DrillDown"></asp:LinkButton>
<br>
</ItemTemplate>
</asp:Repeater>
The OnItemCommand event for the Repeater is connected to the
rptCtrl1_OnItemCommand function:
public void rptCtrl1_OnItemCommand(object source,
System.Web.UI.WebControls.RepeaterCommandEventArgs e)
{
LinkButton lnkButton = (LinkButton)e.CommandSource;
string param = lnkButton.CommandArgument.ToString();
makeDataBind(param);
}
The makeDataBind function will perform the data binding depends on the
link that was clicked. All is fine when the EnableViewState was set to
true for both the repeater and the link button.
When the EnableViewState of the Repeater control is set to false, the
OnItemCommand event doesn't fire;
When the EnableViewState of the Linkbutton is set to false, the
LinkButton is not found in the OnItemCommand event.
I understand that the ViewState is responsible for recreating the
controls on the page. Without the ViewState, the link button was not
recreated so I couldn't get the link button during the event.
But why didn't the Repeater's OnItemCommand event fire when the
ViewState was disabled? If it was a button, the OnClick event will
still fire if the ViewState for the control is set to false.
Is it because the link button won't be recreated if the Repeater's
ViewState was disabled? Without the link button, there was no event to
bubble up?
One other question: With the code above, I can drill down to level 1
from level 0. If I press the back button from level 1, I go back to
level 0. But if I press the back button from level 2, I get a page
cannot be displayed error. If I press the back button again, I go back
to level 0.
I look forward to any advise and suggestions. Thanks in advance.
-Amos