Showing posts with label Listview. Show all posts
Showing posts with label Listview. Show all posts

Thursday, June 25, 2015

Pagination in asp.net Listview control using Datapager

Introduction: In this article I will explain how to implement the paging in asp.net listview control using datapager without using datasource control

Description:
To implement this functionality add a webform to project. Drag and drop the listview and datapager control from toolbox to webform.

HTML markup of webpage:
    <table>
    <tr><td>
        <asp:ListView ID="ListView1" runat="server"
            onpagepropertieschanging="ListView1_PagePropertiesChanging">
        <LayoutTemplate>        
        <table>
  <tr>
  <th>Student Name</th>
  <th>Student Address</th>
  <th>Student Class</th> 
     </tr>
    <tr id="itemPlaceholder" runat="server"></tr>
        </LayoutTemplate>
        <ItemTemplate>
         <tr align="center">
       <td> <asp:Label ID="lblstudentname" runat="server" Text='<%#Eval("Student_Name")%>'></asp:Label></td>
         <td><asp:Label ID="lbladdress" runat="server" Text='<%#Eval("Student_Address") %>'></asp:Label></td>
          <td><asp:Label ID="lblroll" runat="server" Text='<%#Eval("RollNo") %>'></asp:Label></td>
</tr>
        </ItemTemplate>     
        </asp:ListView>
        </td></tr>
        <tr><td></td></tr>
        <tr><td><asp:DataPager ID="DataPager1" runat="server" PagedControlID="ListView1" PageSize="3">
        <Fields><asp:NextPreviousPagerField ButtonType="Link" ShowFirstPageButton="false" ShowPreviousPageButton="true"
                            ShowNextPageButton="false" />
                        <asp:NumericPagerField ButtonType="Link" />
                        <asp:NextPreviousPagerField ButtonType="Link" ShowNextPageButton="true" ShowLastPageButton="false" ShowPreviousPageButton = "false" />
                    </Fields>
        </asp:DataPager></td></tr>
        </table> 

Tuesday, May 7, 2013

How to Bind,Edit,Update and Delete in Listview in Asp.net(C#,VB)


Introduction: In this post I will explain you how to bind, edit, delete and update the Listview data control in Asp.net.

Description:
I have created a table name STUDENT_DETAIL.
STUDENT_ID
int
STUDENT_NAME
varchar(50)
STUDENT_ADDRESS
varchar(50)
STUDENT_CLASS
varchar(50)

STUDENT_ID is primary key.
Now open the Visual Studio>Go to File>New>Website. Add the Connectionstring in web.config file of website.
<configuration>
       <connectionStrings>
    <add name="connection" connectionString="Data Source=SYS-1F78031ED0A;Initial Catalog=TestBlog;Integrated Security=True"/>
       </connectionStrings>
       <system.web>
        <compilation debug="true" targetFramework="4.0" />
    </system.web>
</configuration>

Monday, May 6, 2013

How to Bind Listview using Sqldataadapter, Datatable and Query in Asp.net(C#, VB)


Introduction: In this post I will tell you how to bind the Listview data control in Asp.net.

Description:
I have created a table name STUDENT_DETAIL.
STUDENT_ID
int
STUDENT_NAME
varchar(50)
STUDENT_ADDRESS
varchar(50)
STUDENT_CLASS
varchar(50)

STUDENT_ID is primary key.
Now open the Visual Studio>Go to File>New>Website. Add the Connectionstring in web.config file of website.
<configuration>
       <connectionStrings>
    <add name="connection" connectionString="Data Source=SYS-1F78031ED0A;Initial Catalog=TestBlog;Integrated Security=True"/>
       </connectionStrings>
       <system.web>
        <compilation debug="true" targetFramework="4.0" />
    </system.web>
</configuration>