Hi haider6.9,
I have created a sample which full fill your requirement you need to modify the code according to your requirement.
HTML
<div>
<asp:FormView ID="fvFiles" runat="server" OnPageIndexChanging="OnPageIndexChanging"
AllowPaging="true">
<HeaderTemplate>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<th>
FileId
</th>
<th>
FileName
</th>
<th>
Display
</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<%#Eval("Id")%>
</td>
<td>
<%#Eval("File")%>
</td>
<td>
<asp:HyperLink ID="HyperLink" Text="DisplayPDF" NavigateUrl='<%# Eval("File", "~/{0}") %>'
runat="server" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:FormView>
</div>
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindFormView();
}
}
private void BindFormView()
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "SELECT [Id] ,[File] FROM [File]";
cmd.Connection = con;
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
fvFiles.DataSource = dt;
fvFiles.DataBind();
}
}
}
protected void OnPageIndexChanging(object sender, FormViewPageEventArgs e)
{
fvFiles.PageIndex = e.NewPageIndex;
this.BindFormView();
}
VB.Net
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then
BindFormView()
End If
End Sub
Private Sub BindFormView()
Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Using con As New SqlConnection(constr)
Using cmd As New SqlCommand()
cmd.CommandText = "SELECT [Id] ,[File] FROM [File]"
cmd.Connection = con
Dim sda As New SqlDataAdapter(cmd)
Dim dt As New DataTable()
sda.Fill(dt)
fvFiles.DataSource = dt
fvFiles.DataBind()
End Using
End Using
End Sub
Protected Sub OnPageIndexChanging(sender As Object, e As FormViewPageEventArgs)
fvFiles.PageIndex = e.NewPageIndex
Me.BindFormView()
End Sub
ScreenShot
