Click here to Skip to main content
15,900,816 members

Comments by marounmm (Top 1 by date)

marounmm 5-Sep-13 17:49pm View    
Edit.aspx File:
-----------------
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<contenttemplate>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true"
HeaderText="<%$ Resources:globalresources, validationerrors %>" CssClass="DDValidator" />
<asp:DynamicValidator runat="server" ID="DetailsViewValidator" ControlToValidate="FormView1"
Display="None" CssClass="DDValidator" />
<asp:FormView runat="server" ID="FormView1" DataSourceID="DetailsDataSource" DefaultMode="Edit"
OnItemUpdated="FormView1_ItemUpdated" OnPreRender="FormView1_PreRender"
RenderOuterTable="false" AllowPaging="true">
<edititemtemplate>
<table>
<asp:DynamicEntity runat="server" Mode="Edit" />
<tr class="td">
<td colspan="8" style="border-top: 1px solid #ffffff">
<asp:LinkButton ID="submitButton" runat="server" CommandName="Update"
Text="Update" />
</td>
</tr>
</table>


<asp:LinqDataSource ID="DetailsDataSource" runat="server" EnableUpdate="true">




CodeBehind (Edit.aspx.cs):
--------------------------

public partial class Edit : Page
{
protected MetaTable table;

protected override void OnInit(EventArgs e)
{
base.OnInit(e);
table = DynamicDataRouteHandler.GetRequestMetaTable(Context);
FormView1.SetMetaTable(table);
DetailsDataSource.EntityTypeName = table.EntityType.AssemblyQualifiedName;
}

protected void FormView1_PreRender(object sender, EventArgs e)
{
if (!IsPostBack && Request.QueryString.Count > 0 && Request.QueryString["itidx"] != null)
{
int idx = Convert.ToInt32(Request.QueryString["itidx"]);
if (idx != FormView1.PageIndex) FormView1.PageIndex = idx;
}
}

protected void FormView1_ItemUpdated(object sender, FormViewUpdatedEventArgs e)
{
e.KeepInEditMode = true;
}
}