Hello all,
I am using c#.net
I have a repeater within a View (MultiView) each row contains a ‘Edit’ button (stored on the CommandArgument is the type ID).
<asp:Button ID="buttonClick" OnCommand="ButtonClick" CommandArgument='<%#Eval("ID")%>' runat="server" Text="Edit"/>
When the user clicks on the ‘Edit’ button they are taken through to another view (Edit View).
Dependant on which type Eval("ID") is selected a different UserControl must be visible.
I have noticed that if postback occurs on the same form (Edit View) it loses its state for the dynamic control. Therefore I think I need to access/populate the DIV (appViewArea) via the Page_Load.
Within my Page_Load I only want it to populate the DIV with the correct UserControl if the user has accessed the Edit View. Here is what I currently have within my Page_Load.
if(_multiView1.ActiveViewIndex == 1) // This is the Edit View
{
int typeId = Convert.ToInt32(viewAppointmentID.Value); // viewAppointmentID is a hidden field which is created within the ButtonClick method.
switch (typeId)
{
case 1:
{
var control = Page.LoadControl("~/editBirthAppointment.ascx");
appViewArea.Controls.Add(control);
}
break;
case 2:
{
var control = Page.LoadControl("~/editDeathAppointment.ascx");
appViewArea.Controls.Add(control);
}
break;
}
}
protected void ButtonClick(object sender, CommandEventArgs e)
{
var viewAppointmentID = Convert.ToInt32(e.CommandArgument);
_multiView1.ActiveViewIndex = 1;
}
My problem is that it never goes into the if statament (_mutliview) and it also doesn’t store the viewAppointmentID. I have looked around the web but cannot find anything that really helps me out. Am I accessing it the wrong way?
Thanks in advance for any help.
Thanks
Clare