Wednesday 8 August 2012

"Form view and Repeater Control in asp.net"

formviewrepeater.aspx



<asp:FormView ID="FormView1" runat="server" DataKeyNames="AutoID"
        AllowPaging="true" DataSourceID="SqlDataSource1"
        onpageindexchanged="FormView1_PageIndexChanged"
        onitemcommand="FormView1_ItemCommand">

    <ItemTemplate>
   <h2> Page ID : <asp:Label ID="lblpn" runat="server" Text='<%# Eval("AutoID") %>'></asp:Label></h2>
    Page Name: <asp:Label ID="Label1" runat="server" Text='<%# Eval("PageName") %>'></asp:Label> <br / />

    Page Description :<asp:Label ID="Label2" runat="server" Text='<%# Eval("PageDescription") %>'></asp:Label>
    Page Active : <asp:Label ID="Label3" runat="server" Text='<%# Eval("Active") %>'></asp:Label>
        <asp:LinkButton ID="Edit" runat="server" Text="Edit" CommandName="Edit" />
    </ItemTemplate>

    <EditItemTemplate>
   
    <h2> Page ID : <asp:TextBox ID="txlblpn" runat="server" Text='<%# Eval("AutoID") %>' /></h2>
    Page Name: <asp:TextBox ID="txtLabel1" runat="server" Text='<%# Eval("PageName") %>' /> <br / />

    Page Description :<asp:TextBox ID="txtPD" runat="server" Text='<%# Eval("PageDescription") %>' />
        Page Active : <asp:TextBox ID="txtA" runat="server" Text='<%# Eval("Active") %>' />
        <asp:LinkButton ID="lnkUpdate" runat="server" Text="Update" CommandName="Update" />
        <asp:LinkButton ID="lnkCancel" runat="server" Text="Cancel" CommandName="Cancel" />
   
   
    </EditItemTemplate>
       
    </asp:FormView>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    ConnectionString="<%$ ConnectionStrings:TestConnectionString %>"
   
    SelectCommand="SELECT [AutoID], [PageName], [PageDescription], [Active] FROM [mySampleTable]" >
   
</asp:SqlDataSource>

    <br />
    <br />
    <br />
    <asp:Repeater ID="Repeater1" runat="server"  DataSourceID="SqlDataSource1">
    <ItemTemplate>
   <h2> Page ID : <asp:Label ID="lblpn" runat="server" Text='<%# Eval("AutoID") %>'></asp:Label></h2>
    Page Name: <asp:Label ID="Label1" runat="server" Text='<%# Eval("PageName") %>'></asp:Label> <br / />

    Page Description :<asp:Label ID="Label2" runat="server" Text='<%# Eval("PageDescription") %>'></asp:Label>
    Page Active : <asp:Label ID="Label3" runat="server" Text='<%# Eval("Active") %>'></asp:Label>
        <asp:LinkButton ID="Edit" runat="server" Text="Edit" CommandName="Edit" />
    </ItemTemplate>
    </asp:Repeater>

No comments:

Post a Comment