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
c# asp.net
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.
add a comment |
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
c# asp.net
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
add a comment |
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
c# asp.net
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
c# asp.net
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.
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
add a comment |
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
add a comment |
active
oldest
votes
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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