my griedview code :-
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" RowStyle-BackColor="Black" Font-Names = "Arial" Font-Size = "10pt"
HeaderStyle-BackColor="Black" HeaderStyle-ForeColor="Black" ForeColor="Black" AllowPaging ="true"
OnPageIndexChanging = "OnPaging" PageSize = "5">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Bayan Detail" >
</asp:BoundField>
<%-- <asp:BoundField DataField="Detail" HeaderText="FileName" />--%>
<asp:TemplateField>
<ItemTemplate>
<object type="application/x-shockwave-flash" data='dewplayer-vol.swf?mp3=FileCS.ashx?Id=<%# Eval("Id") %>'
width="240" height="20" id="dewplayer">
<param name="wmode" value="transparent" />
<param name="movie" value='dewplayer-vol.swf?mp3=FileCS.ashx?Id=<%# Eval("Id") %>'/>
</object>
<%-- <audio src=FileCS.ashx?Id=<%# Eval("Id") %> autoplay controls id="audio1">
audio is not supported.--%>
</audio>
</ItemTemplate>
</asp:TemplateField>
<asp:HyperLinkField DataNavigateUrlFields="Id" Text = "Download" DataNavigateUrlFormatString = "~/FileCS.ashx?Id={0}" HeaderText="Download" ControlStyle-ForeColor="Blue" />
</Columns>
<EditRowStyle ForeColor="#003399" />
<HeaderStyle BackColor="#3AC0F2" ForeColor="White"></HeaderStyle>
<RowStyle BackColor="#A1DCF2"></RowStyle>
</asp:GridView>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Configuration;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
}
}
protected void OnPaging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();
}
private void BindGrid()
{
string strConnString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(strConnString))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "select * from tblFiles ORDER BY id DESC";
cmd.Connection = con;
con.Open();
GridView1.DataSource = cmd.ExecuteReader();
GridView1.DataBind();
con.Close();
}
}
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
}
}
Error is
:-
The data source does not support server-side data paging.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NotSupportedException: The data source does not support server-side data paging.
Source Error:
Line 34: con.Open();
Line 35: GridView1.DataSource = cmd.ExecuteReader();
Line 36: GridView1.DataBind(); Line 37: con.Close();
Line 38: }
|
Thanks ...