Post back events not working after dynamically loading template

J

James Meehan

I am dynamically changing the edit item template for a datalist control
by using the LoadTemplate method for an ascx file, but I cannot get the
postback events to work for a button or a link button. If I set the
command name property for the button, the datalist item command event is
not triggered on a postback. If I set the procedure to execute on the
click event, e.g. OnClick = "procedureA", the ascx will not load since
the procedure cannot be found. If I tirgger the postback from a button
on the footer template, then the original edit item template is loaded.
Any ideas? The code loaded from the ascx file is as follows:

<%@ Language = "C#" %>
<TABLE id="tblEdit" cellSpacing="1" cellPadding="1" width="600"
border="0">
<TR>
<TD width="100">
<table>
<tr>
<td>User Name:</td>
</tr>
<tr>
<td><asp:textbox id=txtUserName Text='<%#
DataBinder.Eval(Container,"DataItem.Name") %>' runat="server">
</asp:textbox></td>
<td><asp:requiredfieldvalidator id="vldUserName" Text="*"
ControlToValidate="txtUserName" ErrorMessage="User name is required"
Runat="server"></asp:requiredfieldvalidator></td>
</tr>
</table>
</TD>
<TD width="100">
<table>
<tr>
<td>Password:</td>
</tr>
<tr>
<td><asp:textbox id=txtPassword Text='<%#
DataBinder.Eval(Container,"DataItem.Password") %>' runat="server">
</asp:textbox></td>
<td><asp:requiredfieldvalidator id="vldPassword" Text="*"
ControlToValidate="txtPassword" ErrorMessage="Password is required"
Runat="server"></asp:requiredfieldvalidator></td>
</tr>
</table>
</TD>
<TD width="200">Email Address:
<asp:textbox id=txtEmail Text='<%#
DataBinder.Eval(Container,"DataItem.Email") %>' Runat="server"
TextMode="SingleLine">
</asp:textbox></TD>
</TR>
<TR>
<TD width="100">
<table>
<tr>
<td>Roles:</td>
</tr>
<tr>
<td><asp:checkbox id="chkUser" Text="User"
Runat="server"></asp:checkbox></td>
</tr>
<tr>
<td><asp:checkbox id="chkAdmin" Text="Administrator"
runat="server"></asp:checkbox></td>
</tr>
</table>
</TD>
<TD width="200"><asp:validationsummary id="vldSummary" Runat="server"
Width="100%"></asp:validationsummary></TD>
<TD align="right" width="200">
<asp:linkbutton id="lnkUpdateItem" runat="server"
CommandName="update">Update</asp:linkbutton>&nbsp;&nbsp;
<asp:linkbutton id="lnkCancelItem" runat="server"
CommandName="cancel">Cancel</asp:linkbutton>
</TD>
</TR>
</TABLE>
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top