Get the value of SelectCountMethod

Hi All,

Does anyone know how to get the value of the SelectCountMethod in an ObjectDataSource and add it to the header of a GridView and a textbox?  I am using a BLL, DAL, C#.   There is some  sample code.  Any help would be greatly appreciated.


The code from the DAL is:

FROM phone_Makes
The code from the BLL is:

    public int TotalNumberOfMakes()
        return Adapter.TotalNumberOfMakes().GetValueOrDefault();
The code from the ObjectDataSoure:

        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You are setting the TotalNumberOfMakes() method as SelectCountMethod to the ObjectDataSource. ObjectDataSource uses this method to retrieve a row count internally. So you can use the same method to retrive the row  count. To display this value in the GridView header and a textbox

MakesBLL bll = new MakesBLL(); 
int rowCount = bll.TotalNumberOfMakes();
GridView1.Columns[2].HeaderText = "Total : "  + rowCount.ToString();
TextBox1.Text = = rowCount.ToString();

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Justice75Author Commented:

Thank you for your response.  Should that be in the GridView1_Load method or some other one?  Thank you.. This worked perfect.

Justice75Author Commented:
Clear, concise and straight to the point!
Justice75Author Commented:
Also, When I added it to the Columns[2] it replaced the header text for that column.  Is there any way that it can go on the row with the paging mechanism?

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.