如何检查EntityDataSource的WhereParameters是否返回0行

时间:2012-06-18 10:09:57

标签: c# asp.net

我有一个EntityDataSource:

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

我动态添加这些WhereParameters:

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

如何检查WhereParameters是否返回0行(无)?

哦是的,如果我的代码错了,请帮助并告诉我..谢谢!

1 个答案:

答案 0 :(得分:1)

使用查询完成后将发生的OnSelected事件:

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

了解详情:here