Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP.Net Gridview Paging=True Record Count

Status
Not open for further replies.

tqeonline

MIS
Oct 5, 2009
304
US
Hello All,

I have been trying for the past couple hours trying to get the # of results to show up on this query.

I have a query that runs to a gridview and paging is enabled.

I need to know the exact number of results that are displayed.

I am doing it all in VB.

Gridview = GridView1
DataSource = SqlDataSource1

If there was a cool way to make it show something like

"You are view results 1 to 10 out of 678" That'd be ideal.
 
The SQLsource is listed as a "Dataset".

I don't know what you mean by "Definition" but here is the code I have it pulling from the tables.

Code:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:INTABLESConnectionString %>" 
                    
                    
                    SelectCommand="SELECT Stock_Num AS Location, Stock_Desc AS Description, Stock_QOH AS QOH, GMPN + ' ' + DelphiPN + ' ' + FCIPN + ' ' + MolexPN + ' ' + MolexPN + ' ' + TycoPN + ' ' + YazakiPN + ' ' + EPCPN + ' ' + Other AS PN FROM Stock_Info WHERE (Stock_QOH &gt; 0) AND (GMPN + ' ' + DelphiPN + ' ' + FCIPN + ' ' + MolexPN + ' ' + MolexPN + ' ' + TycoPN + ' ' + YazakiPN + ' ' + EPCPN + ' ' + Other LIKE '%' + ? + '%') UNION ALL SELECT Stock_Num AS Location, Stock_Desc AS Description, Stock_QOH AS QOH, Stock_PN AS PN FROM ManEntry WHERE (Stock_QOH &gt; 0) AND (Stock_PN LIKE '%' + ? + '%')" 
                    
                    
                    ProviderName="<%$ ConnectionStrings:INTABLESConnectionString.ProviderName %>">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="txtSearch" Name="?" PropertyName="Text" 
                            DefaultValue="%" />
                        <asp:ControlParameter ControlID="txtSearch" DefaultValue="%" Name="?" 
                            PropertyName="Text" />
                    </SelectParameters>
                </asp:SqlDataSource>

The only thing I did for the paging to work is set paging = true. I limit each page to 10 results.
 
I see. One possibility could be to convert this into SP and add output parameter @TotalCount = @@ROWCOUNT and grab this parameter's value in Selected event of SQL Data Source.

However, I'm not sure how paging is done with SQLDataSource under the hood. Is it getting all the result and then doing paging on the client or it somehow limits the number of records on the server (that would be the right approach).

I suggest asking this question in this forum

you have better chances of getting the good answer.

PluralSight Learning Library
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top