bdz
bdz

Reputation: 321

How to check whether the WhereParameters of an EntityDataSource returns 0 rows

I have an EntityDataSource:

<asp:EntityDataSource ID="EntityDataSourcePersoneel"
            runat="server"
            ConnectionString="name=HotelTestDatabaseEntities"
            DefaultContainerName="HotelTestDatabaseEntities"
            EntitySetName="Personeels"
            Include="Afdeling">
   </asp:EntityDataSource>

I dynamically add these WhereParameters:

EntityDataSourcePersoneel.WhereParameters.Clear();
   EntityDataSourcePersoneel.AutoGenerateWhereClause = true;
   EntityDataSourcePersoneel.WhereParameters.Add("personeelID", TypeCode.Int32  
   personeelId.ToString());

How can I check if WhereParameters returns 0 rows (nothing)?

Oh yeah, if my code is wrong, please help and advise me.. Thanks!

Upvotes: 0

Views: 348

Answers (1)

dtsg
dtsg

Reputation: 4459

Use the OnSelected event which will occur after a query has finished executing:

protected void EntityDataSourcePersoneel_OnSelected(object Sender, EntityDataSourceSelectedEventArgs e)
{
     if(e.TotalRowCount == 0)
     {
          //Whatever
     }
}

Read more: here

Upvotes: 1

Related Questions