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

[Solved] Finding Grid Data Client Side

1 Answer 106 Views
Grid
This is a migrated thread and some comments may be shown as answers.
DK
Top achievements
Rank 2
DK asked on 16 Aug 2009, 08:51 AM
I have a radgrid.
now when page loads then i want to check weather the grid have data or it is empty.
i have used getcoumnnamebyuniquename ......  property.
it works fine when grid have data but when the grid is empty then it gives javascript error.
that undefined is null or not an object.
please help me in this regard.

how can i check client side page load that grid have data or not?

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 17 Aug 2009, 04:49 AM
Hello,

Try the following client-side code in order to check whether grid is empty or not.

JavaScript:
 
<script type="text/javascript"
function pageLoad() 
    var grid = $find("<%=RadGrid1.ClientID %>"); 
    var MasterTable = grid.get_masterTableView(); 
    var rows = MasterTable.get_dataItems(); 
    if(rows.length == 0) 
    { 
        alert("Empty"); 
    } 
    else 
    { 
        alert('Not Empty'); 
    } 
</script> 

-Shinu.
Tags
Grid
Asked by
DK
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Share this question
or