This is a migrated thread and some comments may be shown as answers.

grid row count

3 Answers 160 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Priya
Top achievements
Rank 1
Priya asked on 05 Aug 2008, 10:10 AM
Sir,
Is ther any way to get row count of grid both of current page n entire pages not from itemDatabound.

Thanks

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 05 Aug 2008, 10:35 AM
Hi Priya,

Try the following code snippet to achieve the desired scenario.

1.To get the row count of the current page:

 protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        int rowcount = RadGrid1.MasterTableView.Items.Count; 
    } 


2. To get the row count of entire pages:

protected void RadGrid1_ItemEvent(object sender, GridItemEventArgs e) 
    { 
         if (e.EventInfo is GridInitializePagerItem) 
         { 
           int allRowsCount = (e.EventInfo as GridInitializePagerItem).PagingManager.DataSourceCount; 
         } 
    } 


Cheers
Shinu
0
Priya
Top achievements
Rank 1
answered on 05 Aug 2008, 11:46 AM

its working fine
thanks alot for ur quick response


I hav another problem,
I have two tables and the grid is bound with the 1st table.But there is a column which shows data from the 2nd table.That is achieved by a userdefined funtion which returns the data based on the arguments(eg:foreignkey) passed to it.This fn is calld in each itemdatabound.The prblm is i want to filter that 2nd table data.As the filtering is applied on grid's bounded data,it becomes a prbm for me.
I Enter the filtering expression in txtFilter which is not a child ctrl of grid.
In the userdefined fn I store the args of the fn is a session object as

 

Protected

Function ParseMessage(ByVal nWFCode As Integer, ByVal bIsRejected As Boolean, _

ByVal bIsHistory As Boolean, Optional ByVal sType As String = "P", _

Optional ByVal sDocId As String = "", _

Optional ByVal dbConn As SqlConnection = Nothing) As String

sStatusDesc = WorkFlowMessages.GetMessage(nWFCode, bIsRejected, bIsHistory, sType, sDocId, dbConn)

If

(txtFilter.Text <> "" And txtFilter.Text = sStatusDesc) Then

ViewState(

"StatDocid") += sDocId + ","

End If

In NeedDataSource event

ds = GetDataSet()

Dim

docid As String = ViewState("StatDocid")

Dim filterExpression As String

Dim list As DropDownList = DirectCast(((txtFilter.NamingContainer).FindControl("drpFilterOnField")), DropDownList)

If (docid <> "") Then

Dim docidcnt As Integer = docid.Length

docid = docid.Remove(docidcnt - 1, 1)

filterExpression =

"(DocumentId in(" + docid + "))"

Dim dv As New DataView()

dv.Table = ds.Tables(0)

dv.RowFilter = filterExpression

WorkDetailsGrid.DataSource = dv

In WorkDetailsGrid_PreRender event

WorkDetailsGrid.MasterTableView.Rebind()

But it is not working.Is ther any way to solve my prbm.I bacme mad due to it
Plz help me

Thanks

0
Priya
Top achievements
Rank 1
answered on 06 Aug 2008, 04:21 AM
Plz help me
Tags
Grid
Asked by
Priya
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Priya
Top achievements
Rank 1
Share this question
or