Wednesday 8 October 2014

DataPager Control Using ListView Show Details in Asp.Net C#

DataPager Control 

DataPager control can be associated with the data-bound control by using the PagedControlID property. Alternatively, by putting the DataPager control inside the data-bound control hierarchy. For example, in the ListView control, DataPager control can be kept inside the ListView-LayoutTemplate.




                 DEMO




                      
                           Html Coding


<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
</head>
<body>
  
  
    <form id="form1" runat="server">

<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1">

            <AlternatingItemTemplate>
                <tr style="background-color#FAFAD2;color#284775;">
                    <td>
             <asp:Label ID="nameLabel" runat="server" 
Text='<%# Eval("name"%>' />
                    </td>
                    <td>
 <asp:Label ID="emailLabel" runat="server" Text='<%# Eval("email"%>' />
                    </td>
                    <td>
                        <asp:Label ID="mobileLabel" runat="server" 
Text='<%# Eval("mobile"%>' />
                    </td>
                    <td>
                        <asp:Label ID="usernameLabel" runat="server" 
Text='<%# Eval("username"%>' />
                    </td>
                    <td>
                        <asp:Label ID="passwordLabel" runat="server" 
Text='<%# Eval("password"%>' />
                    </td>
                </tr>
            </AlternatingItemTemplate>
            <EditItemTemplate>
                <tr style="background-color#FFCC66;color#000080;">
                    <td>
                        <asp:Button ID="UpdateButton" runat="server" 
CommandName="Update" Text="Update" />
                        <asp:Button ID="CancelButton" runat="server" 
CommandName="Cancel" Text="Cancel" />
                    </td>
                    <td>
                        <asp:TextBox ID="nameTextBox" runat="server" 
Text='<%# Bind("name"%>' />
                    </td>
                    <td>
                        <asp:TextBox ID="emailTextBox" runat="server"
 Text='<%# Bind("email"%>' />
                    </td>
                    <td>
                        <asp:TextBox ID="mobileTextBox" runat="server"
 Text='<%# Bind("mobile"%>' />
                    </td>
                    <td>
                        <asp:TextBox ID="usernameTextBox" runat="server"
 Text='<%# Bind("username"%>' />
                    </td>
                    <td>
                        <asp:TextBox ID="passwordTextBox" runat="server" 
Text='<%# Bind("password"%>' />
                    </td>
                </tr>
            </EditItemTemplate>
            <EmptyDataTemplate>
                <table id="Table1" runat="server" style="background-color#FFFFFF;border-collapsecollapse;border-color#999999;border-style:none;border-width:1px;">
                    <tr>
                        <td>No data was returned.</td>
                    </tr>
                </table>
            </EmptyDataTemplate>
            <InsertItemTemplate>
                <tr style="">
                    <td>
                        <asp:Button ID="InsertButton" runat="server" 
CommandName="Insert" Text="Insert" />
                        <asp:Button ID="CancelButton" runat="server"
 CommandName="Cancel" Text="Clear" />
                    </td>
                    <td>
                        <asp:TextBox ID="nameTextBox" runat="server"
 Text='<%# Bind("name"%>' />
                    </td>
                    <td>
                        <asp:TextBox ID="emailTextBox" runat="server"
Text='<%# Bind("email"%>' />
                    </td>
                    <td>
                        <asp:TextBox ID="mobileTextBox" runat="server" 
Text='<%# Bind("mobile"%>' />
                    </td>
                    <td>
                        <asp:TextBox ID="usernameTextBox" runat="server"
Text='<%# Bind("username"%>' />
                    </td>
                    <td>
                        <asp:TextBox ID="passwordTextBox" runat="server" Text='<%# Bind("password"%>' />
                    </td>
                </tr>
            </InsertItemTemplate>
            <ItemTemplate>
                <tr style="background-color#FFFBD6;color#333333;">
                    <td>
                        <asp:Label ID="nameLabel" runat="server"
 Text='<%# Eval("name"%>' />
                    </td>
                    <td>
              <asp:Label ID="emailLabel" runat="server" 
Text='<%# Eval("email"%>' />
                    </td>
                    <td>
                        <asp:Label ID="mobileLabel" runat="server" 
Text='<%# Eval("mobile"%>' />
                    </td>
                    <td>
                        <asp:Label ID="usernameLabel" runat="server" 
Text='<%# Eval("username"%>' />
                    </td>
                    <td>
                        <asp:Label ID="passwordLabel" runat="server" 
Text='<%# Eval("password"%>' />
                    </td>
                </tr>
            </ItemTemplate>
            <LayoutTemplate>
                <table id="Table2" runat="server">
                    <tr id="Tr1" runat="server">
                        <td id="Td1" runat="server">
                            <table id="itemPlaceholderContainer" runat="server" border="1" style="background-color#FFFFFF;border-collapsecollapse;border-color#999999;border-style:none;border-width:1px;font-familyVerdanaArialHelveticasans-serif;">
                                <tr id="Tr2" runat="server" style="background-color#FFFBD6;color#333333;">
                                    <th id="Th1" runat="server">name</th>
                                    <th id="Th2" runat="server">email</th>
                                 <th id="Th3" runat="server">mobile</th>
                                 <th id="Th4" runat="server">username</th>
                                 <th id="Th5" runat="server">password</th>
                                </tr>
                                <tr id="itemPlaceholder" runat="server">
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr id="Tr3" runat="server">
                        <td id="Td2" runat="server" style="text-aligncenter;background-color#FFCC66;font-familyVerdanaArialHelveticasans-serif;color#333333;">
                            <asp:DataPager ID="DataPager1" runat="server">
                                <Fields>
                                    <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                    <asp:NumericPagerField />
                                    <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                </Fields>
                            </asp:DataPager>
                        </td>
                    </tr>
                </table>
            </LayoutTemplate>
            <SelectedItemTemplate>
                <tr style="background-color#FFCC66;font-weightbold;color#000080;">
                    <td>
                        <asp:Label ID="nameLabel" runat="server" 
Text='<%# Eval("name"%>' />
                    </td>
                    <td>
                        <asp:Label ID="emailLabel" runat="server"
 Text='<%# Eval("email"%>' />
                    </td>
                    <td>
                        <asp:Label ID="mobileLabel" runat="server" 
Text='<%# Eval("mobile"%>' />
                    </td>
                    <td>
                        <asp:Label ID="usernameLabel" runat="server"
 Text='<%# Eval("username"%>' />
                    </td>
                    <td>
                        <asp:Label ID="passwordLabel" runat="server"
Text='<%# Eval("password"%>' />
                    </td>
                </tr>
            </SelectedItemTemplate>
        </asp:ListView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:dbcon %>" SelectCommand="SELECT * FROM [register]"></asp:SqlDataSource>
    </form> 
  
</body>


</html>



                                      




















                                                               

0 comments:

Post a Comment