Newbie: 2 state control in a repeater

L

Lloyd Dupont

I'm trying to create a Weblog control in which I have a list of entry and
each could be either in edit or view mode (pseudo-code below)

my problem is I don't really know how to manage everyone's state well over
the postback...

I was thinking to save the Value of my switch in the ViewState and modify it
with my button, but because it's set in the asp code, it never changes.....

I'm confused, any one know how to make this work ?

//------- pseudo code ---------
<script runat=server>
protected override OnInit()
{
// get data
DataBind();
}
void OnSwapEdit()
{
// ... ??
}
</script>
<asp:Repeater: id=blogRepeat runat=server>
<ItemTemplate>

<myctrl:Switch runat=server value="view">

<myctrl:Case runat=server Value="view">
<myctrl:BlogView runat=server Value=<%# Container.DataItem
%> /> <br/>
<asp:LinkButton Runat=server Text=Edit OnClick=OnSwapEdit
/>
</myctrl:Case>

<myctrl:Case runat=server Value="edit">
<myctrl:BlogEdit runat=server Value=<%# Container.DataItem
%> /> <br/>
<asp:LinkButton Runat=server Text=Save OnClick=OnSwapEdit
/>
</myctrl:Case>

</myctrl:Switch>
</ItemTemplate>
</asp:Repeater>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top