Click here to Skip to main content
15,918,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi ,
i want to show how many rows does a gridview contains using stored procedure not using loops. for that what i have done is as follows:
SQL
alter  proc spgridStates
@CountryId int
as
begin
select [StatesName ],country.[CountryName ] as Countries ,country.CountryId  ,states.StateId   from Country,States where Country.CountryId = @CountryId and States.CountryId = @CountryId
  union all
select 'Total States',null,(select COUNT(*) from States   where States.CountryId = @CountryId  ),null   States
end


when i am binding it to gridview it works fine i.e shows the rows a table contains in my case states,country table. But now the major problem i m facing is as the total of rows is coming in gridview and as my gridview has autogenerate select,delete,edit button "true" that final row also appears with edit ,delete and update so i want to show that last row in footer how can i?
Posted

1 solution

Here is a sample i'm providing, i've a label in a templated field at the footer.

protected void Page_Load(object sender, EventArgs e)
{

GridView1.DataSource = EmployeeByCountry("UK");
GridView1.DataBind();
Label lblFooter = GridView1.FooterRow.FindControl("lblFooter") as Label;
lblFooter.Text = GetNoOfRows().ToString();
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900