ASP.NET Gridview paging not working for me









up vote
-1
down vote

favorite













Error is given to below section.




C# Code



Here GlobalApp is my class library...



public List<Student> GetAllStudents()

string sql = "select name,subject,rollNo from students";
SqlDataReader reader = GlobalApp.GetReader(sql);
List<Student> students = new List<Student>();
while (reader.Read())

Student aStudent = new Student();
aStudent.name = reader["name"];
aStudent.subject = reader["subject"];
aStudent.rollNo = reader["rollNo"];
students.Add(aStudent);

reader.Close();
GlobalApp.CloseConnection();
return students;

protected void showAllButton_Click(object sender, EventArgs e)

try

studentsGridView.DataSource = GetAllStudents();
studentsGridView.DataBind();

catch (Exception exception)

Label1.Text = "" + exception;







HTML CODE



<asp:GridView ID="studentsGridView" runat="server" Width="226px" CellPadding="4" ForeColor="#333333" GridLines="None">

<Columns>
<asp:BoundField DataField="name" HeaderText="Name" />
<asp:BoundField DataField="subject" HeaderText="Subject" />
<asp:BoundField DataField="rollNo" HeaderText="Roll No" />
</Columns>
</asp:GridView>


Class



public class Student

public object name get; set;
public object subject get; set;
public object rollNo get; set;




System.InvalidOperationException: The data source for GridView with id
'studentsGridView' did not have any properties or attributes from
which to generate columns. Ensure that your data source has content.
at
System.Web.UI.WebControls.GridViewColumnsGenerator.CreateAutoGeneratedFields(Object
dataObject, Control control) at
System.Web.UI.WebControls.AutoFieldsGenerator.GenerateFields(Control
control) at
System.Web.UI.WebControls.GridView.CreateColumns(PagedDataSource
dataSource, Boolean useDataSource) at
System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable
dataSource, Boolean dataBinding) at
System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable
data) at
System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable
data) at
System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable
data) at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments
arguments, DataSourceViewSelectCallback callback) at
System.Web.UI.WebControls.DataBoundControl.PerformSelect() at
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() at
System.Web.UI.WebControls.GridView.DataBind() at
HMS.UI.Start.showAllButton_Click(Object sender, EventArgs e) in
e:ProjectsHMSHMSDefault.aspx.cs:line 80











share|improve this question









New contributor




Nohas Tanvir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 1




    Your formatting only harms your chances to get answer. Format the question so that only important parts were highlighted. If you don't know what to highlight, don't highlight anything. Use citation formatting for stack trace.
    – svgrafov
    Nov 9 at 15:16














up vote
-1
down vote

favorite













Error is given to below section.




C# Code



Here GlobalApp is my class library...



public List<Student> GetAllStudents()

string sql = "select name,subject,rollNo from students";
SqlDataReader reader = GlobalApp.GetReader(sql);
List<Student> students = new List<Student>();
while (reader.Read())

Student aStudent = new Student();
aStudent.name = reader["name"];
aStudent.subject = reader["subject"];
aStudent.rollNo = reader["rollNo"];
students.Add(aStudent);

reader.Close();
GlobalApp.CloseConnection();
return students;

protected void showAllButton_Click(object sender, EventArgs e)

try

studentsGridView.DataSource = GetAllStudents();
studentsGridView.DataBind();

catch (Exception exception)

Label1.Text = "" + exception;







HTML CODE



<asp:GridView ID="studentsGridView" runat="server" Width="226px" CellPadding="4" ForeColor="#333333" GridLines="None">

<Columns>
<asp:BoundField DataField="name" HeaderText="Name" />
<asp:BoundField DataField="subject" HeaderText="Subject" />
<asp:BoundField DataField="rollNo" HeaderText="Roll No" />
</Columns>
</asp:GridView>


Class



public class Student

public object name get; set;
public object subject get; set;
public object rollNo get; set;




System.InvalidOperationException: The data source for GridView with id
'studentsGridView' did not have any properties or attributes from
which to generate columns. Ensure that your data source has content.
at
System.Web.UI.WebControls.GridViewColumnsGenerator.CreateAutoGeneratedFields(Object
dataObject, Control control) at
System.Web.UI.WebControls.AutoFieldsGenerator.GenerateFields(Control
control) at
System.Web.UI.WebControls.GridView.CreateColumns(PagedDataSource
dataSource, Boolean useDataSource) at
System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable
dataSource, Boolean dataBinding) at
System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable
data) at
System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable
data) at
System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable
data) at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments
arguments, DataSourceViewSelectCallback callback) at
System.Web.UI.WebControls.DataBoundControl.PerformSelect() at
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() at
System.Web.UI.WebControls.GridView.DataBind() at
HMS.UI.Start.showAllButton_Click(Object sender, EventArgs e) in
e:ProjectsHMSHMSDefault.aspx.cs:line 80











share|improve this question









New contributor




Nohas Tanvir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 1




    Your formatting only harms your chances to get answer. Format the question so that only important parts were highlighted. If you don't know what to highlight, don't highlight anything. Use citation formatting for stack trace.
    – svgrafov
    Nov 9 at 15:16












up vote
-1
down vote

favorite









up vote
-1
down vote

favorite












Error is given to below section.




C# Code



Here GlobalApp is my class library...



public List<Student> GetAllStudents()

string sql = "select name,subject,rollNo from students";
SqlDataReader reader = GlobalApp.GetReader(sql);
List<Student> students = new List<Student>();
while (reader.Read())

Student aStudent = new Student();
aStudent.name = reader["name"];
aStudent.subject = reader["subject"];
aStudent.rollNo = reader["rollNo"];
students.Add(aStudent);

reader.Close();
GlobalApp.CloseConnection();
return students;

protected void showAllButton_Click(object sender, EventArgs e)

try

studentsGridView.DataSource = GetAllStudents();
studentsGridView.DataBind();

catch (Exception exception)

Label1.Text = "" + exception;







HTML CODE



<asp:GridView ID="studentsGridView" runat="server" Width="226px" CellPadding="4" ForeColor="#333333" GridLines="None">

<Columns>
<asp:BoundField DataField="name" HeaderText="Name" />
<asp:BoundField DataField="subject" HeaderText="Subject" />
<asp:BoundField DataField="rollNo" HeaderText="Roll No" />
</Columns>
</asp:GridView>


Class



public class Student

public object name get; set;
public object subject get; set;
public object rollNo get; set;




System.InvalidOperationException: The data source for GridView with id
'studentsGridView' did not have any properties or attributes from
which to generate columns. Ensure that your data source has content.
at
System.Web.UI.WebControls.GridViewColumnsGenerator.CreateAutoGeneratedFields(Object
dataObject, Control control) at
System.Web.UI.WebControls.AutoFieldsGenerator.GenerateFields(Control
control) at
System.Web.UI.WebControls.GridView.CreateColumns(PagedDataSource
dataSource, Boolean useDataSource) at
System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable
dataSource, Boolean dataBinding) at
System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable
data) at
System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable
data) at
System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable
data) at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments
arguments, DataSourceViewSelectCallback callback) at
System.Web.UI.WebControls.DataBoundControl.PerformSelect() at
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() at
System.Web.UI.WebControls.GridView.DataBind() at
HMS.UI.Start.showAllButton_Click(Object sender, EventArgs e) in
e:ProjectsHMSHMSDefault.aspx.cs:line 80











share|improve this question









New contributor




Nohas Tanvir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












Error is given to below section.




C# Code



Here GlobalApp is my class library...



public List<Student> GetAllStudents()

string sql = "select name,subject,rollNo from students";
SqlDataReader reader = GlobalApp.GetReader(sql);
List<Student> students = new List<Student>();
while (reader.Read())

Student aStudent = new Student();
aStudent.name = reader["name"];
aStudent.subject = reader["subject"];
aStudent.rollNo = reader["rollNo"];
students.Add(aStudent);

reader.Close();
GlobalApp.CloseConnection();
return students;

protected void showAllButton_Click(object sender, EventArgs e)

try

studentsGridView.DataSource = GetAllStudents();
studentsGridView.DataBind();

catch (Exception exception)

Label1.Text = "" + exception;







HTML CODE



<asp:GridView ID="studentsGridView" runat="server" Width="226px" CellPadding="4" ForeColor="#333333" GridLines="None">

<Columns>
<asp:BoundField DataField="name" HeaderText="Name" />
<asp:BoundField DataField="subject" HeaderText="Subject" />
<asp:BoundField DataField="rollNo" HeaderText="Roll No" />
</Columns>
</asp:GridView>


Class



public class Student

public object name get; set;
public object subject get; set;
public object rollNo get; set;




System.InvalidOperationException: The data source for GridView with id
'studentsGridView' did not have any properties or attributes from
which to generate columns. Ensure that your data source has content.
at
System.Web.UI.WebControls.GridViewColumnsGenerator.CreateAutoGeneratedFields(Object
dataObject, Control control) at
System.Web.UI.WebControls.AutoFieldsGenerator.GenerateFields(Control
control) at
System.Web.UI.WebControls.GridView.CreateColumns(PagedDataSource
dataSource, Boolean useDataSource) at
System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable
dataSource, Boolean dataBinding) at
System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable
data) at
System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable
data) at
System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable
data) at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments
arguments, DataSourceViewSelectCallback callback) at
System.Web.UI.WebControls.DataBoundControl.PerformSelect() at
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() at
System.Web.UI.WebControls.GridView.DataBind() at
HMS.UI.Start.showAllButton_Click(Object sender, EventArgs e) in
e:ProjectsHMSHMSDefault.aspx.cs:line 80








c# asp.net






share|improve this question









New contributor




Nohas Tanvir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Nohas Tanvir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Nov 9 at 17:16









Jack

911522




911522






New contributor




Nohas Tanvir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 9 at 15:12









Nohas Tanvir

1




1




New contributor




Nohas Tanvir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Nohas Tanvir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Nohas Tanvir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 1




    Your formatting only harms your chances to get answer. Format the question so that only important parts were highlighted. If you don't know what to highlight, don't highlight anything. Use citation formatting for stack trace.
    – svgrafov
    Nov 9 at 15:16












  • 1




    Your formatting only harms your chances to get answer. Format the question so that only important parts were highlighted. If you don't know what to highlight, don't highlight anything. Use citation formatting for stack trace.
    – svgrafov
    Nov 9 at 15:16







1




1




Your formatting only harms your chances to get answer. Format the question so that only important parts were highlighted. If you don't know what to highlight, don't highlight anything. Use citation formatting for stack trace.
– svgrafov
Nov 9 at 15:16




Your formatting only harms your chances to get answer. Format the question so that only important parts were highlighted. If you don't know what to highlight, don't highlight anything. Use citation formatting for stack trace.
– svgrafov
Nov 9 at 15:16

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






Nohas Tanvir is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53228360%2fasp-net-gridview-paging-not-working-for-me%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes








Nohas Tanvir is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















Nohas Tanvir is a new contributor. Be nice, and check out our Code of Conduct.












Nohas Tanvir is a new contributor. Be nice, and check out our Code of Conduct.











Nohas Tanvir is a new contributor. Be nice, and check out our Code of Conduct.













 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53228360%2fasp-net-gridview-paging-not-working-for-me%23new-answer', 'question_page');

);

Post as a guest














































































Popular posts from this blog

Kleinkühnau

Makov (Slowakei)

Deutsches Schauspielhaus