Not too sure wat u r trying to achive, but datasource to any of the data-bound control should be an object from which it retrieves its list of data items.
I think u should just consider using label in this case.
well I put allow paging - true on the Object data source and I get this
ObjectDataSource 'ObjectDataSource2' could not find a non-generic method 'GetDataByU18' that has parameters: maximumRows, startRowIndex.
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.InvalidOperationException: ObjectDataSource 'ObjectDataSource2' could not find a non-generic method 'GetDataByU18' that has parameters: maximumRows, startRowIndex.
Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
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.Data.ConstraintException: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
Description: An error occurred during the parsing of a resource required to service this request. Please review
the following specific parse error details and modify your source file appropriately.
Parser Error Message: System.Web.UI.WebControls.DataControlFieldCollection must have items of type 'System.Web.UI.WebControls.DataControlField'. 'asp:Label' is of type 'System.Web.UI.WebControls.Label'.
Description:
An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: System.Web.UI.WebControls.DataControlFieldCollection must have items of type 'System.Web.UI.WebControls.DataControlField'. 'asp:Label' is of type 'System.Web.UI.WebControls.Label'.
Description: An error occurred during the parsing of a resource required to service this request. Please review
the following specific parse error details and modify your source file appropriately.
Parser Error Message: System.Web.UI.WebControls.DataControlFieldCollection must have items of type 'System.Web.UI.WebControls.DataControlField'. 'asp:Label' is of type 'System.Web.UI.WebControls.Label'.
prontonet
Member
243 Points
484 Posts
Select Count Queries in gridview
Dec 26, 2012 10:19 PM|LINK
hi,
is it possible to display select Count queries in Gridiew? or should I use a Label?
I seem to get an error everytime
For example
SELECT COUNT(*) FROM table_name
I am using an Object Data source.
thank you for advice.
AZMatt
Star
10648 Points
1896 Posts
Re: Select Count Queries in gridview
Dec 26, 2012 10:57 PM|LINK
You should be able to. What does the error message say?
Matt
Ramesh T
Contributor
5121 Points
827 Posts
Re: Select Count Queries in gridview
Dec 26, 2012 11:10 PM|LINK
Not too sure wat u r trying to achive, but datasource to any of the data-bound control should be an object from which it retrieves its list of data items.
I think u should just consider using label in this case.
prontonet
Member
243 Points
484 Posts
Re: Select Count Queries in gridview
Dec 26, 2012 11:29 PM|LINK
well I put allow paging - true on the Object data source and I get this
ObjectDataSource 'ObjectDataSource2' could not find a non-generic method 'GetDataByU18' that has parameters: maximumRows, startRowIndex.
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.InvalidOperationException: ObjectDataSource 'ObjectDataSource2' could not find a non-generic method 'GetDataByU18' that has parameters: maximumRows, startRowIndex.
prontonet
Member
243 Points
484 Posts
Re: Select Count Queries in gridview
Dec 26, 2012 11:31 PM|LINK
and with paging false I get
Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
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.Data.ConstraintException: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
Source Error:
oned_gk
All-Star
31511 Points
6431 Posts
Re: Select Count Queries in gridview
Dec 26, 2012 11:35 PM|LINK
<asp:Label id="Label1" runat="server" text='<%# Eval("Total") %>' />prontonet
Member
243 Points
484 Posts
Re: Select Count Queries in gridview
Dec 27, 2012 12:07 AM|LINK
hi getting the error
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: System.Web.UI.WebControls.DataControlFieldCollection must have items of type 'System.Web.UI.WebControls.DataControlField'. 'asp:Label' is of type 'System.Web.UI.WebControls.Label'.
Source Error:
anurag003iit...
Member
176 Points
111 Posts
Re: Select Count Queries in gridview
Dec 27, 2012 07:40 AM|LINK
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: System.Web.UI.WebControls.DataControlFieldCollection must have items of type 'System.Web.UI.WebControls.DataControlField'. 'asp:Label' is of type 'System.Web.UI.WebControls.Label'.
hi try this to solve this error
http://www.codeproject.com/Questions/80899/answer.aspx
KiaranNafade
Member
134 Points
58 Posts
Re: Select Count Queries in gridview
Dec 27, 2012 07:48 AM|LINK
adp = new SqlDataAdapter("Select count(*) from fees_paid", con);
ds = new DataSet();
adp.Fill(ds);
GridView4.DataSource = ds;
GridView4.DataBind();
Click mark a answer if helps for u.
oned_gk
All-Star
31511 Points
6431 Posts
Re: Select Count Queries in gridview
Dec 27, 2012 07:52 AM|LINK
Do you place the label inside itemtemplate?