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.

Jus


The code from the DAL is:

SELECT COUNT(*)
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" 
            SelectMethod="GetMakesPagesAndSorted" 
            TypeName="MakesBLL" 
            EnablePaging="True" 
            OldValuesParameterFormatString="original_{0}" 
            SelectCountMethod="TotalNumberOfMakes" 
            SortParameterName="sortExpression">
            <SelectParameters>
            </SelectParameters>            
        </asp:ObjectDataSource>

Open in new window

Justice75Asked:
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.

RameshSCommented:
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

0

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:
Ramesh,

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

Jus
0
Justice75Author Commented:
Clear, concise and straight to the point!
0
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?

Jus
0
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.