How to find total no. of rows in gridview

m using c# .net and oracledatabase with 3 tier architecture.

i want to find the total number of records in the entire gridview.

M sending the source code of my gridview and the method which i m using to display records in gridview.
please tell how to do this…

public void LoadApplication()
{
try
{
gvApplication.DataSource = null;
gvApplication.DataBind();
BLApplication objApplication = new BLApplication();
DataSet ds = new DataSet();
objCls = new ClsApplication();
objCls.supId = Session[“USERNAME”].ToString();
ds = objApplication.GetApplication(objCls);

        if (ds.Tables[0].Rows.Count > 0)
        {
            gvApplication.DataSource = ds;
            gvApplication.DataBind();
        }
    }
       catch (Exception ex)
       {
         lblMessage.Text = ex.Message;
       }
     }

<asp:GridView ID=“gvApplication” runat=“server” OnSelectedIndexChanged=“GridView1_SelectedIndexChanged”
AutoGenerateColumns=“False” UseAccessibleHeader=“False” CssClass=“GridRowFormat” AutoGenerateEditButton=“true” OnRowDataBound=“gvApplication_RowDataBound” OnRowCancelingEdit=“gvApplication_RowCancelingEdit” OnRowEditing=“gvApplication_RowEditing” OnRowUpdating=“gvApplication_RowUpdating” AllowPaging=“True” OnPageIndexChanged=“gvApplication_PageIndexChanged” OnPageIndexChanging=“gvApplication_PageIndexChanging” BorderColor=“#404040” BorderStyle=“Solid” BorderWidth=“2px”>
<HeaderStyle CssClass=“DataGridFixedHeader” Wrap=“True” Font-Size=“Small” />
<Columns>
<asp:TemplateField HeaderText=“Application Name”>
<ItemTemplate>
<%# Eval(“APPLICATION_NAME”) %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID=“txtAppname” runat=“Server” Text=‘<%# Eval(“APPLICATION_NAME”) %>’>
</asp:TextBox>
<asp:TextBox ID=“txtAppnameOld” runat=“Server” Text=‘<%# Eval(“APPLICATION_id”) %>’ Visible=“false”>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=“Status”>
<ItemTemplate >
<%# Eval(“Status”) %>
</ItemTemplate>
<EditItemTemplate>
<asp:RadioButtonList ID=“rdlstStatus” runat=server RepeatDirection=Horizontal>
<asp:ListItem Text=“Yes” Value=“Y”></asp:ListItem>
<asp:ListItem Text=“No” Value=“N”></asp:ListItem>
</asp:RadioButtonList>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
<AlternatingRowStyle CssClass=“GridRowAlternative” />
<PagerSettings FirstPageText=“First” LastPageText=“Last” Mode=“NextPreviousFirstLast”
NextPageText=“Next” PreviousPageText=“Prev” />
</asp:GridView>

Hello,

// If your datasource is DataSet

DataSet ds=new DataSet();

ds=GetRecords(); // Retrieveing records from database
lblRecords.Text=ds.Tables[0].Rows.Count; // this is your label displaying total records

Gridview1.DataSource=ds;

Gridview1.DataBind();

May be This will solve your problem.

Also check this url http://forums.asp.net/t/1405252.aspx

public void LoadApplication()
{
try
{
gvApplication.DataSource = null;
gvApplication.DataBind();
BLApplication objApplication = new BLApplication();
DataSet ds = new DataSet();
objCls = new ClsApplication();
objCls.supId = Session[“USERNAME”].ToString();
ds = objApplication.GetApplication(objCls);

if (ds.Tables[0].Rows.Count > 0)
{
gvApplication.DataSource = ds;
gvApplication.DataBind();
}
}

catch (Exception ex)
{
lblMessage.Text = ex.Message;
}
}

if (ds.Tables[0].Rows.Count > 0)
{
[B]lblMessage.Text = ds.Tables[0].Rows.Count;[/B]
gvApplication.DataSource = ds;
gvApplication.DataBind();
}

}

add this in your code

lblMessage.Text = ds.Tables[0].Rows.Count.ToString();

i did this n got the number of records. but i want to display that in gridview like this…check this link…
http://www.demohelpdesk.com/main.php?filter=user

in this gridview it gives 13 entries on the bottom of gridview. Like ths i want to display in my gridview.

Hello,

did you check this link http://forums.asp.net/t/1405252.aspx in this you can got your answer.
check it carefully.

yes i checked this and many other links…i did showfooter property to true.
but confused in writing the code in rowdatabound event using footer. In the link it is not properly visible…
Please guide me what to write in this event.
protected void gvApplication_RowDataBound(object sender, GridViewRowEventArgs e)
{
}

In label m getting the value of total records. and i did the showfooter property to true.
Now i want to display this value in the bottom of gridview how to do this? Is there anything to write on gridview rowdatabount event? if yes then please guide.

if (ds.Tables[0].Rows.Count > 0)
{
lblMessage.Text = ds.Tables[0].Rows.Count;
gvApplication.DataSource = ds;
gvApplication.DataBind();
}

hi,

wild guess i think you have to write this

protected void gvApplication_RowDataBound(object sender, GridViewRowEventArgs e)
{
    DataSet ds=new DataSet();

     ds=GetRecords(); // Retrieveing records from database
     lblMessage.Text=ds.Tables[0].Rows.Count.ToString(); // this is your label displaying total records

    gvApplication.DataSource = ds;
    gvApplication.DataBind();
}

hope u got success.

Have you try this one

Rows: GridView1.Rows.Count

Columns: GridView1.Columns.Count